Пример #1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "getbutton":                                            //根据用户的权限获取用户点击的菜单有权限的按钮
                    string    pageName = context.Request.Params["pagename"];
                    string    menuCode = context.Request.Params["menucode"]; //菜单标识码
                    DataTable dt       = new ZGZY.BLL.Button().GetButtonByMenuCodeAndUserId(menuCode, user.Id);
                    context.Response.Write(ZGZY.Common.ToolbarHelper.GetToolBar(dt, pageName));
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;    //输出参数
                    string strJson = new ZGZY.BLL.Button().GetPager("tbButton", "Id,Name,Code,Icon,Sort,AddDate,Description", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询按钮";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    //ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "getall":
                    context.Response.Write(new ZGZY.BLL.Button().GetAllButton("1=1"));
                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "按钮功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                //ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #2
0
        /// <summary>
        /// 写入操作日志
        /// </summary>
        public void InsertOperateLog(Model.UserOperateLog userOperateLog)
        {
            string sql = "insert into tbUserOperateLog(UserName,UserIp,OperateInfo,IfSuccess,Description) values (@UserName,@UserIp,@OperateInfo,@IfSuccess,@Description)";

            SqlParameter[] paras =
            {
                new SqlParameter("@UserName",    userOperateLog.UserName),
                new SqlParameter("@UserIp",      userOperateLog.UserIp),
                new SqlParameter("@OperateInfo", userOperateLog.OperateInfo),
                new SqlParameter("@IfSuccess",   userOperateLog.IfSuccess),
                new SqlParameter("@Description", userOperateLog.Description)
            };
            DriveMgr.Common.SqlHelper.ExecuteNonQuery(DriveMgr.Common.SqlHelper.connStr, CommandType.Text, sql, paras);
        }
Пример #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User user = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_loginlog_username       = context.Request.Params["ui_loginlog_username"] ?? "";
                    string ui_loginlog_userip         = context.Request.Params["ui_loginlog_userip"] ?? "";
                    string ui_loginlog_city           = context.Request.Params["ui_loginlog_city"] ?? "";
                    string ui_loginlog_success        = context.Request.Params["ui_loginlog_success"] ?? "";
                    string ui_loginlog_logindatestart = context.Request.Params["ui_loginlog_logindatestart"] ?? "";
                    string ui_loginlog_logindateend   = context.Request.Params["ui_loginlog_logindateend"] ?? "";

                    if (ui_loginlog_username.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_loginlog_username))       //防止sql注入
                    {
                        strWhere += string.Format(" and UserName like '%{0}%'", ui_loginlog_username.Trim());
                    }
                    if (ui_loginlog_userip.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_loginlog_userip))
                    {
                        strWhere += string.Format(" and UserIp like '%{0}%'", ui_loginlog_userip.Trim());
                    }
                    if (ui_loginlog_city.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_loginlog_city))
                    {
                        strWhere += string.Format(" and City like '%{0}%'", ui_loginlog_city.Trim());
                    }
                    if (ui_loginlog_success.Trim() != "select" && ui_loginlog_success.Trim() != "")
                    {
                        strWhere += " and Success = '" + ui_loginlog_success.Trim() + "'";
                    }
                    if (ui_loginlog_logindatestart.Trim() != "")
                    {
                        strWhere += " and LoginDate > '" + ui_loginlog_logindatestart.Trim() + "'";
                    }
                    if (ui_loginlog_logindateend.Trim() != "")
                    {
                        strWhere += " and LoginDate < '" + ui_loginlog_logindateend.Trim() + "'";
                    }

                    string strJson = new DriveMgr.BLL.LoginLog().GetPager(strWhere, sort, order, pageindex, pagesize);
                    context.Response.Write(strJson);
                    userOperateLog.OperateInfo = "查询登陆日志";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "export":      //导出

                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "登陆日志功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;                    //操作日志对象
            try {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context); //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "getUserMenu":      //获取特定用户能看到的菜单(左侧树)
                    context.Response.Write(new ZGZY.BLL.Menu().GetUserMenu(user.Id));
                    break;

                case "getAllMenu":                                                  //根据角色id获取此角色有的权限(设置角色时自动勾选已经有的按钮权限)
                    int roleid = Convert.ToInt32(context.Request.Params["roleid"]); //角色id
                    context.Response.Write(new ZGZY.BLL.Menu().GetAllMenu(roleid));
                    break;

                case "getMyAuthority":      //前台根据用户名查“我的权限”
                    context.Response.Write(new ZGZY.BLL.Menu().GetMyAuthority(user.Id));
                    userOperateLog.OperateInfo = "查询我的信息";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询我的信息";
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"] == null ? "Id" : context.Request.Params["sort"];    //排序列
                    string order     = context.Request.Params["order"] == null ? "asc" : context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;            //输出参数
                    string strJson = "";          //输出结果
                    if (order.IndexOf(',') != -1) //如果有","就是多列排序(不能拿列判断,列名中间可能有","符号)
                    {
                        //多列排序:
                        //sort:ParentId,Sort,AddDate
                        //order:asc,desc,asc
                        string   sortMulti  = "";              //拼接排序条件,例:ParentId desc,Sort asc
                        string[] sortArray  = sort.Split(','); //列名中间有","符号,这里也要出错。正常不会有
                        string[] orderArray = order.Split(',');
                        for (int i = 0; i < sortArray.Length; i++)
                        {
                            sortMulti += sortArray[i] + " " + orderArray[i] + ",";
                        }
                        strJson = new ZGZY.BLL.Menu().GetPager("tbMenu", "Id,Name,ParentId,Code,LinkAddress,Icon,Sort,AddDate", sortMulti.Trim(','), pagesize, pageindex, strWhere, out totalCount);
                        userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sortMulti.Trim(',') + " 页码/每页大小:" + pageindex + " " + pagesize;
                    }
                    else
                    {
                        strJson = new ZGZY.BLL.Menu().GetPager("tbMenu", "Id,Name,ParentId,Code,LinkAddress,Icon,Sort,AddDate", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                        userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    }

                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询菜单";
                    userOperateLog.IfSuccess   = true;
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    DbHelper db      = new DbHelper();
                    Result   rs      = new Result();
                    string   sqlMenu = @"insert into tbMenu(name,parentid,code,linkaddress,adddate)
                                    values('{0}',{1},'{2}','{3}',getdate());";

                    string formType   = context.Request["formType"];
                    string formName   = context.Request["formName"];
                    string mainFormID = context.Request["mainFormID"];
                    string htmlPath   = context.Request["htmlPath"];
                    string sqlExist   = "select count(1) from tbMenu where name='" + formName + "';";
                    int    count      = db.ExecuteScalar(sqlExist);
                    if (count > 0)
                    {
                        rs.status = 0;
                        rs.msg    = "该界面名称已经存在,请检查。";
                        context.Response.Write("{\"msg\":\"该界面名称已经存在,请检查。\",\"success\":false}");
                        return;
                    }
                    else
                    {
                        if (formType == "mainForm")
                        {
                            sqlMenu = string.Format(sqlMenu, formName, "0", "", "");
                        }
                        else
                        {
                            sqlMenu = string.Format(sqlMenu, formName, mainFormID, "Function", htmlPath);
                        }

                        string sqlMenuButton = "insert into tbMenuButton select id, 1 from tbmenu where name='" + formName + "';";

                        if (db.ExecuteNonQuery(sqlMenu) == 1)
                        {
                            if (db.ExecuteNonQuery(sqlMenuButton) == 1)
                            {
                                rs.status = 1;
                                rs.msg    = "保存成功!";
                            }
                        }
                        else
                        {
                            rs.status = 0;
                            rs.msg    = "服务器繁忙,请稍后再试!";
                        }
                    }

                    rs.item = "[]";
                    string json = JsonConvert.SerializeObject(rs);

                    context.Response.Clear();
                    context.Response.ContentEncoding = Encoding.UTF8;
                    context.Response.ContentType     = "application/json";
                    context.Response.Write(json);
                    context.Response.Flush();
                    context.Response.End();

                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            } catch (Exception ex) {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "菜单功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User user = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "getall":
                    context.Response.Write(new DriveMgr.BLL.Role().GetAllRole("1=1"));
                    break;

                case "getallwithoutsuper":
                    context.Response.Write(new DriveMgr.BLL.Role().GetAllRole("1=1 and Id<>1"));
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.Role().GetPager("tbRole", "Id,RoleName,AddDate,ModifyDate,Description", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询角色";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "searchRoleUser":
                    int    roleUserId        = int.Parse(context.Request.Params["roleId"]);
                    string sortRoleUser      = context.Request.Params["sort"];  //排序列
                    string orderRoleUser     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindexRoleUser = int.Parse(context.Request.Params["page"]);
                    int    pagesizeRoleUser  = int.Parse(context.Request.Params["rows"]);

                    string strJsonRoleUser = new DriveMgr.BLL.Role().GetPagerRoleUser(roleUserId, sortRoleUser + " " + orderRoleUser, pagesizeRoleUser, pageindexRoleUser);
                    context.Response.Write(strJsonRoleUser);
                    userOperateLog.OperateInfo = "查询角色用户";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询角色Id:" + roleUserId + " 排序:" + sortRoleUser + " " + orderRoleUser + " 页码/每页大小:" + pageindexRoleUser + " " + pagesizeRoleUser;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("role", "add", user.Id))
                    {
                        string ui_role_rolename_add    = context.Request.Params["ui_role_rolename_add"] ?? "";
                        string ui_role_description_add = context.Request.Params["ui_role_description_add"] ?? "";

                        DriveMgr.Model.Role roleAdd = new Model.Role();
                        roleAdd.RoleName    = ui_role_rolename_add;
                        roleAdd.Description = ui_role_description_add.Trim();

                        int roleId = new DriveMgr.BLL.Role().AddRole(roleAdd);
                        if (roleId > 0)
                        {
                            userOperateLog.OperateInfo = "添加角色";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,角色主键:" + roleId;
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加角色";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加角色";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("role", "edit", user.Id))
                    {
                        int    id                       = Convert.ToInt32(context.Request.Params["id"]);
                        string originalName             = context.Request.Params["originalName"] ?? "";
                        string ui_role_rolename_edit    = context.Request.Params["ui_role_rolename_edit"] ?? "";
                        string ui_role_description_edit = context.Request.Params["ui_role_description_edit"] ?? "";

                        DriveMgr.Model.Role roleEdit = new Model.Role();
                        roleEdit.Id          = id;
                        roleEdit.RoleName    = ui_role_rolename_edit;
                        roleEdit.Description = ui_role_description_edit.Trim();

                        if (new DriveMgr.BLL.Role().EditRole(roleEdit, originalName))
                        {
                            userOperateLog.OperateInfo = "修改角色";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,角色主键:" + roleEdit.Id;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改角色";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改角色";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("role", "delete", user.Id))
                    {
                        int id = Convert.ToInt32(context.Request.Params["id"]);
                        if (new DriveMgr.BLL.Role().DeleteRole(id))
                        {
                            userOperateLog.OperateInfo = "删除角色";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,角色主键:" + id;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除角色";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败";
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除角色";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "authorize":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("role", "authorize", user.Id))
                    {
                        int    roleId       = Convert.ToInt32(context.Request.Params["roleId"]); //要授权的角色id
                        string menuButtonId = context.Request.Params["menuButtonId"].Trim(',');  //具体的菜单和按钮权限
                        if (new DriveMgr.BLL.Role().Authorize(roleId, menuButtonId))
                        {
                            userOperateLog.OperateInfo = "角色授权";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "授权成功,菜单/按钮Id:" + menuButtonId;
                            context.Response.Write("{\"msg\":\"授权成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "角色授权";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "授权失败";
                            context.Response.Write("{\"msg\":\"授权失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "角色授权";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "角色功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_studentsArchives_name         = context.Request.Params["ui_studentsArchives_name"] ?? "";
                    string ui_studentsArchives_code         = context.Request.Params["ui_studentsArchives_code"] ?? "";
                    string ui_studentsArchives_cardnum      = context.Request.Params["ui_studentsArchives_cardnum"] ?? "";
                    string ui_studentsArchives_archivescode = context.Request.Params["ui_studentsArchives_archivescode"] ?? "";

                    strWhere += " and flag=1";
                    if (ui_studentsArchives_name.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_studentsArchives_name))       //防止sql注入
                    {
                        strWhere += string.Format(" and StudentsName like '%{0}%'", ui_studentsArchives_name.Trim());
                    }
                    if (ui_studentsArchives_code.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_studentsArchives_code))
                    {
                        strWhere += string.Format(" and StudentCode like '%{0}%'", ui_studentsArchives_code.Trim());
                    }
                    if (ui_studentsArchives_cardnum.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_studentsArchives_cardnum))
                    {
                        strWhere += string.Format(" and CardNum like '%{0}%'", ui_studentsArchives_cardnum.Trim());
                    }
                    if (ui_studentsArchives_archivescode.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_studentsArchives_archivescode))
                    {
                        strWhere += string.Format(" and ArchivesCode like '%{0}%'", ui_studentsArchives_archivescode.Trim());
                    }


                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.ArchivesBLL().GetPager("V_Archives", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询档案";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("archives", "edit", userFromCookie.Id))
                    {
                        int    id = Convert.ToInt32(context.Request.Params["archivesid_edit"]);
                        string ui_archives_remark_edit = context.Request.Params["ui_archives_remark_edit"] ?? "";

                        DriveMgr.Model.ArchivesModel archivesEdit = new Model.ArchivesModel();
                        archivesEdit.ID     = id;
                        archivesEdit.Remark = ui_archives_remark_edit.Trim();


                        if (new DriveMgr.BLL.ArchivesBLL().Update(archivesEdit))
                        {
                            userOperateLog.OperateInfo = "修改档案信息";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,档案主键:" + archivesEdit.ID;
                            context.Response.Write("{\"msg\":\"修改档案信息成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改档案信息";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改档案信息";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "档案功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;
                JavaScriptSerializer jsonSerialize = new JavaScriptSerializer();
                switch (action)
                {
                case "getbutton":                                            //根据用户的权限获取用户点击的菜单有权限的按钮
                    string    pageName = context.Request.Params["pagename"];
                    string    menuCode = context.Request.Params["menucode"]; //菜单标识码
                    DataTable dt       = new ZGZY.BLL.Customers().GetButtonByMenuCodeAndUserId(menuCode, user.Id);
                    string    sum      = ZGZY.Common.ToolbarHelper.GetToolBar(dt, pageName);
                    context.Response.Write(sum);
                    break;

                case "add":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("Channel", "add", user.Id))
                    {
                        Model.Finance FinanceModel = new Model.Finance();
                        FinanceModel.FinanceName = context.Request.Params["ui_Finance_FinanceName_add"];
                        FinanceModel.ChannelId   = Int32.Parse(context.Request.Params["ui_Finance_ChannelID"]);
                        FinanceModel.ManagerId   = 72;
                        FinanceModel.State       = Int32.Parse(context.Request.Params["ui_Finance_State_add"]);
                        FinanceModel.CreateDate  = DateTime.Now;
                        FinanceModel.FinanceType = Int32.Parse(context.Request.Params["ui_Finance_FinanceType_add"]);
                        FinanceModel.Remark      = context.Request.Params["ui_Finance_Remark_add"];
                        FinanceModel.FinanceNum  = Int32.Parse(context.Request.Params["ui_Finance_FinanceNum_add"]);
                        FinanceModel.Amount      = Int32.Parse(context.Request.Params["ui_Finance_Amount_add"]);
                        int departmentId = new ZGZY.BLL.Finance().AddFinance(FinanceModel);
                        if (departmentId > 0)
                        {
                            Model.CustomerFinance cusFin = new Model.CustomerFinance();
                            cusFin.CusId     = Int32.Parse(context.Request.Params["ui_Finance_CustomersID"]);
                            cusFin.FinanceId = departmentId;
                            cusFin.BeginDate = DateTime.Parse(context.Request.Params["ui_Finance_BeginDate_add"]);
                            cusFin.EndDate   = DateTime.Parse(context.Request.Params["ui_Finance_EndDate_add"]);
                            new ZGZY.BLL.CustomerFinance().AddCustomerFinance(cusFin);

                            userOperateLog.OperateInfo = "添加结算";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,客户主键:" + departmentId;
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加结算";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加结算";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "GetChannelList":
                    List <Model.VW_GetEndDateAndBeginDateByChannelID> list = new ZGZY.BLL.Finance().GetFinanceFromCombobox();
                    context.Response.Write(jsonSerialize.Serialize(list));
                    //string strjson = GetJsonStr(list);
                    //context.Response.Write(strjson);  GetDateById
                    break;

                case "GetCustomersList":
                    List <Model.Customers> listCus = new ZGZY.BLL.Customers().GetCustomersTbaleNoP();
                    context.Response.Write(jsonSerialize.Serialize(listCus));
                    break;

                case "GetDateById":
                    object Id = context.Request.Params["Id"];
                    Model.VW_GetEndDateAndBeginDateByChannelID model = new ZGZY.BLL.Finance().Get_VWDate(Id);
                    context.Response.Write(jsonSerialize.Serialize(model));
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;    //输出参数
                    string strJson = new ZGZY.BLL.Button().GetPager("VW_FinanceAndChannel", "UserName,Id,CusId,CusName, FinanceName,BeginDate,EndDate, ChannelId, ManagerId, State, CreateDate, FinanceType, Remark, Amount, FinanceNum, ChannelName, Creator, SealNameId", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询按钮";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("Channel", "edit", user.Id))
                    {
                        Model.Finance financemodel = new Model.Finance();
                        financemodel.Id          = Int32.Parse(context.Request.Params["ID"]);
                        financemodel.FinanceName = context.Request.Params["ui_Finance_FinanceName_edit"];
                        financemodel.ChannelId   = Int32.Parse(context.Request.Params["ui_Finance_ChannelID_edit"]);
                        financemodel.State       = Int32.Parse(context.Request.Params["ui_Finance_State_edit"]);
                        financemodel.FinanceType = Int32.Parse(context.Request.Params["ui_Finance_FinanceType_edit"]);
                        financemodel.FinanceNum  = Int32.Parse(context.Request.Params["ui_Finance_FinanceNum_edit"]);
                        financemodel.Amount      = double.Parse(context.Request.Params["ui_Finance_Amount_edit"]);
                        financemodel.Remark      = context.Request.Params["ui_Finance_Remark_edit"];
                        int outputRow = new ZGZY.BLL.Finance().EditFinanceByFinanceID(financemodel);
                        Model.CustomerFinance modelCusFin = new Model.CustomerFinance();
                        modelCusFin.FinanceId = financemodel.Id;
                        modelCusFin.BeginDate = DateTime.Parse(context.Request.Params["ui_Finance_BeginDate_edit"]);
                        modelCusFin.EndDate   = DateTime.Parse(context.Request.Params["ui_Finance_EndDate_edit"]);
                        modelCusFin.CusId     = Int32.Parse(context.Request.Params["ui_Finance_CustomersID_edit"]);
                        outputRow            += new ZGZY.BLL.CustomerFinance().EditCustomerFinanceByFinanceId(modelCusFin);
                        if (outputRow == 2)
                        {
                            userOperateLog.OperateInfo = "修改结算";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,客户主键:" + outputRow;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改结算";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改结算";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("Channel", "delete", user.Id))
                    {
                        object departmentIds = context.Request.Params["id"];
                        if (new ZGZY.BLL.Finance().DeleteFinanceByFinanceID(departmentIds) == 1)
                        {
                            userOperateLog.OperateInfo = "删除结算";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,结算主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除结算";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败,客户主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除结算";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "菜单功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);


                    string ui_students_name    = context.Request.Params["ui_students_name"] ?? "";
                    string ui_students_code    = context.Request.Params["ui_students_code"] ?? "";
                    string ui_students_cardnum = context.Request.Params["ui_students_cardnum"] ?? "";
                    string ui_students_status  = context.Request.Params["ui_students_status"] ?? "";
                    string ui_pay_status       = context.Request.Params["ui_pay_status"] ?? "";
                    string ui_students_period  = context.Request.Params["ui_students_period"] ?? "";


                    //string ui_user_userid = context.Request.Params["ui_user_userid"] ?? "";
                    //string ui_user_username = context.Request.Params["ui_user_username"] ?? "";
                    //string ui_user_isable = context.Request.Params["ui_user_isable"] ?? "";
                    //string ui_user_ifchangepwd = context.Request.Params["ui_user_ifchangepwd"] ?? "";
                    //string ui_user_description = context.Request.Params["ui_user_description"] ?? "";
                    //string ui_user_adddatestart = context.Request.Params["ui_user_adddatestart"] ?? "";
                    //string ui_user_adddateend = context.Request.Params["ui_user_adddateend"] ?? "";
                    strWhere += " and flag=1";
                    if (ui_students_name.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_students_name))       //防止sql注入
                    {
                        strWhere += string.Format(" and StudentsName like '%{0}%'", ui_students_name.Trim());
                    }
                    if (ui_students_code.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_students_code))
                    {
                        strWhere += string.Format(" and StudentCode like '%{0}%'", ui_students_code.Trim());
                    }
                    if (ui_students_cardnum.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_students_cardnum))
                    {
                        strWhere += string.Format(" and CardNum like '%{0}%'", ui_students_cardnum.Trim());
                    }
                    if (ui_students_status.Trim() != "select" && ui_students_status.Trim() != "")
                    {
                        strWhere += " and Status = '" + ui_students_status.Trim() + "'";
                    }
                    if (ui_pay_status.Trim() != "select" && ui_pay_status.Trim() != "")
                    {
                        strWhere += " and PayStatus = '" + ui_pay_status.Trim() + "'";
                    }
                    if (ui_students_period.Trim() != "select" && ui_students_period.Trim() != "")
                    {
                        strWhere += " and PeriodsID = '" + ui_students_period.Trim() + "'";
                    }


                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.RegistrationBLL().GetPager("V_StudentsBaseData", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询学员";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "add", userFromCookie.Id))
                    {
                        string ui_registration_name_add    = context.Request.Params["ui_registration_name_add"] ?? "";
                        string ui_registration_cardnum_add = context.Request.Params["ui_registration_cardnum_add"] ?? "";
                        int    ui_registration_age_add     = Int32.Parse(context.Request.Params["ui_registration_age_add"] ?? "-1");
                        bool   ui_registration_sex_add     = context.Request.Params["ui_registration_sex_add"] == "0" ? false : true;
                        bool   ui_registration_islocal_add = context.Request.Params["ui_registration_islocal_add"] == "0" ? false : true;
                        int    ui_registration_period_add  = Int32.Parse(context.Request.Params["ui_registration_period_add"] ?? "-1");
                        string ui_registration_address_add = context.Request.Params["ui_registration_address_add"] ?? "";
                        string ui_registration_remark_add  = context.Request.Params["ui_registration_remark_add"] ?? "";
                        string fupPic_add = context.Request.Params["fupPic_add"] ?? "";
                        string ui_registration_phoneNum_add = context.Request.Params["ui_registration_phoneNum_add"] ?? "";

                        DriveMgr.Model.RegistrationModel registrationAdd = new Model.RegistrationModel();
                        registrationAdd.StudentsName = ui_registration_name_add;
                        registrationAdd.CardNum      = ui_registration_cardnum_add;
                        registrationAdd.Age          = ui_registration_age_add;
                        registrationAdd.Sex          = ui_registration_sex_add;
                        registrationAdd.IsLocal      = ui_registration_islocal_add;
                        registrationAdd.PeriodsID    = ui_registration_period_add;
                        registrationAdd.Address      = ui_registration_address_add;
                        registrationAdd.Remark       = ui_registration_remark_add;
                        registrationAdd.Status       = 0; //【0:在学 1:毕业 2:退学】
                        if (fupPic_add.Trim() == "")
                        {
                            registrationAdd.PicPath = "";
                        }
                        else
                        {
                            registrationAdd.PicPath = "/images/Pictures/" + fupPic_add;
                        }
                        registrationAdd.PhoneNum = ui_registration_phoneNum_add;

                        FormsIdentity             id      = (FormsIdentity)context.User.Identity;
                        FormsAuthenticationTicket tickets = id.Ticket;

                        //获取票证里序列化的用户对象(反序列化)
                        DriveMgr.Model.User userCheck = new JavaScriptSerializer().Deserialize <DriveMgr.Model.User>(tickets.UserData);

                        registrationAdd.Operater = userCheck.UserName;
                        DriveMgr.BLL.RegistrationBLL bll = new DriveMgr.BLL.RegistrationBLL();
                        bool result = bll.Add(registrationAdd);
                        if (result)
                        {
                            //RegistrationModel mod = bll.GetModel(result);
                            //string changeMsg = String.Empty;
                            //try
                            //{
                            //    string srcPath = context.Server.MapPath(mod.PicPath);
                            //    string extension = Path.GetFileNameWithoutExtension(srcPath);
                            //    string desPath = context.Server.MapPath("/admin/images/Pictures/" + mod.CardNum + ".jpg");
                            //    bool changeResult = FileHelpercs.ChangeFileName(srcPath, desPath);

                            //    if (changeResult)
                            //    {
                            //        changeMsg = "改变照片名称成功!从" + srcPath + "到" + desPath;
                            //    }
                            //    else
                            //    {
                            //        changeMsg = "改变照片名称失败!从" + srcPath + "到" + desPath;
                            //    }
                            //}
                            //catch
                            //{
                            //    changeMsg = "改变照片名称失败!";
                            //}

                            userOperateLog.OperateInfo = "添加学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,学员" + ui_registration_name_add;
                            context.Response.Write("{\"msg\":\"添加学员成功!" + "\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "edit", userFromCookie.Id))
                    {
                        int    id = Convert.ToInt32(context.Request.Params["id"]);
                        string ui_registration_name_edit     = context.Request.Params["ui_registration_name_edit"] ?? "";
                        string ui_registration_cardnum_edit  = context.Request.Params["ui_registration_cardnum_edit"] ?? "";
                        int    ui_registration_age_edit      = Int32.Parse(context.Request.Params["ui_registration_age_edit"] ?? "-1");
                        bool   ui_registration_sex_edit      = context.Request.Params["ui_registration_sex_edit"] == "0" ? false : true;
                        bool   ui_registration_islocal_edit  = context.Request.Params["ui_registration_islocal_edit"] == "0" ? false : true;
                        int    ui_registration_period_edit   = Int32.Parse(context.Request.Params["ui_registration_period_edit"] ?? "-1");
                        string ui_registration_address_edit  = context.Request.Params["ui_registration_address_edit"] ?? "";
                        string ui_registration_remark_edit   = context.Request.Params["ui_registration_remark_edit"] ?? "";
                        string ui_registration_phoneNum_edit = context.Request.Params["ui_registration_phoneNum_edit"] ?? "";

                        DriveMgr.Model.RegistrationModel registrationedit = new Model.RegistrationModel();
                        registrationedit.ID           = id;
                        registrationedit.StudentsName = ui_registration_name_edit;
                        registrationedit.CardNum      = ui_registration_cardnum_edit;
                        registrationedit.Age          = ui_registration_age_edit;
                        registrationedit.Sex          = ui_registration_sex_edit;
                        registrationedit.IsLocal      = ui_registration_islocal_edit;
                        registrationedit.PeriodsID    = ui_registration_period_edit;
                        registrationedit.Address      = ui_registration_address_edit;
                        registrationedit.Remark       = ui_registration_remark_edit;
                        //registrationedit.Status = 0; //【0:在学 1:毕业 2:退学】
                        registrationedit.PhoneNum = ui_registration_phoneNum_edit;      //手机号码

                        FormsIdentity             iid     = (FormsIdentity)context.User.Identity;
                        FormsAuthenticationTicket tickets = iid.Ticket;

                        //获取票证里序列化的用户对象(反序列化)
                        DriveMgr.Model.User userCheck = new JavaScriptSerializer().Deserialize <DriveMgr.Model.User>(tickets.UserData);

                        registrationedit.Operater = userCheck.UserName;

                        if (new DriveMgr.BLL.RegistrationBLL().Update(registrationedit))
                        {
                            userOperateLog.OperateInfo = "修改学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,学员主键:" + registrationedit.ID;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "delete", userFromCookie.Id))
                    {
                        string ids = context.Request.Params["id"].Trim(',');
                        if (new DriveMgr.BLL.RegistrationBLL().DeleteList(ids))
                        {
                            userOperateLog.OperateInfo = "删除学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,学员主键:" + ids;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败";
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "bindPeroid":
                    DataTable dt           = new DriveMgr.BLL.RegistrationBLL().BindPeroid();
                    string    peroidResult = NewtonJsonHelper.ToJson(dt);
                    context.Response.Write(peroidResult);
                    break;

                case "pay":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "paytuition", userFromCookie.Id))
                    {
                        bool payResult = DoTuition(context);
                        if (payResult)
                        {
                            userOperateLog.OperateInfo = "缴纳学费";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "交费成功。";
                            context.Response.Write("{\"msg\":\"交费成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "缴纳学费";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "交费失败";
                            context.Response.Write("{\"msg\":\"交费失败!\",\"success\":false}");
                        }
                    }
                    break;

                case "payExam":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "payExam", userFromCookie.Id))
                    {
                        bool payResult = PayExam(context);
                        if (payResult)
                        {
                            userOperateLog.OperateInfo = "缴纳考试费";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "交费成功。";
                            context.Response.Write("{\"msg\":\"交考试费成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "缴纳考试费";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "交考试费失败";
                            context.Response.Write("{\"msg\":\"交考试费失败!\",\"success\":false}");
                        }
                    }
                    break;

                case "exit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "exit", userFromCookie.Id))
                    {
                        bool exitResult = DropOut(context);
                        if (exitResult)
                        {
                            userOperateLog.OperateInfo = "退学";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "退学成功。";
                            context.Response.Write("{\"msg\":\"退学成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "退学";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "退学失败";
                            context.Response.Write("{\"msg\":\"退学失败!\",\"success\":false}");
                        }
                    }
                    break;

                case "getInfoByCard":
                    string infoResult = GetInfoByCard(context);
                    context.Response.Write(infoResult);
                    break;

                case "uploadPic":
                    string uploadResult = UploadPic(context);
                    context.Response.Write(uploadResult);
                    break;

                case "printApplyTable":
                    string printResult = PrintApplyTable(context);
                    context.Response.Write(printResult);
                    break;

                case "exportStudents":
                    string exportResult = DownloadExcel(context);
                    context.Response.Write(exportResult);
                    break;

                case "addByCard":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("registration", "byCard", userFromCookie.Id))
                    {
                        string ui_registration_name_byCard     = context.Request.Params["ui_registration_name_byCard"] ?? "";
                        string ui_registration_cardnum_byCard  = context.Request.Params["ui_registration_cardnum_byCard"] ?? "";
                        int    ui_registration_age_byCard      = Int32.Parse(context.Request.Params["ui_registration_age_byCard"] ?? "-1");
                        bool   ui_registration_sex_byCard      = context.Request.Params["ui_registration_sex_byCard"] == "0" ? false : true;
                        bool   ui_registration_islocal_byCard  = context.Request.Params["ui_registration_islocal_byCard"] == "0" ? false : true;
                        int    ui_registration_period_byCard   = Int32.Parse(context.Request.Params["ui_registration_period_byCard"] ?? "-1");
                        string ui_registration_address_byCard  = context.Request.Params["ui_registration_address_byCard"] ?? "";
                        string ui_registration_remark_byCard   = context.Request.Params["ui_registration_remark_byCard"] ?? "";
                        string ui_registration_phoneNum_byCard = context.Request.Params["ui_registration_phoneNum_byCard"] ?? "";

                        string fupPic_byCard = context.Request.Params["picPath"] ?? "";

                        DriveMgr.Model.RegistrationModel registrationAdd = new Model.RegistrationModel();
                        registrationAdd.StudentsName = ui_registration_name_byCard;
                        registrationAdd.CardNum      = ui_registration_cardnum_byCard;
                        registrationAdd.Age          = ui_registration_age_byCard;
                        registrationAdd.Sex          = ui_registration_sex_byCard;
                        registrationAdd.IsLocal      = ui_registration_islocal_byCard;
                        registrationAdd.PeriodsID    = ui_registration_period_byCard;
                        registrationAdd.Address      = ui_registration_address_byCard;
                        registrationAdd.Remark       = ui_registration_remark_byCard;
                        registrationAdd.Status       = 0; //【0:在学 1:毕业 2:退学】
                        if (fupPic_byCard.Replace("/images/Pictures/", "").Trim() == "")
                        {
                            registrationAdd.PicPath = "";
                        }
                        else
                        {
                            registrationAdd.PicPath = fupPic_byCard;
                        }
                        registrationAdd.PhoneNum = ui_registration_phoneNum_byCard;

                        FormsIdentity             id      = (FormsIdentity)context.User.Identity;
                        FormsAuthenticationTicket tickets = id.Ticket;

                        //获取票证里序列化的用户对象(反序列化)
                        DriveMgr.Model.User userCheck = new JavaScriptSerializer().Deserialize <DriveMgr.Model.User>(tickets.UserData);

                        registrationAdd.Operater = userCheck.UserName;
                        DriveMgr.BLL.RegistrationBLL bll = new DriveMgr.BLL.RegistrationBLL();
                        bool result = bll.Add(registrationAdd);
                        if (result)
                        {
                            userOperateLog.OperateInfo = "刷卡添加学员";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,学员" + ui_registration_name_byCard;
                            context.Response.Write("{\"msg\":\"添加学员成功!" + "\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "刷卡添加学员";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "刷卡添加学员";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "uploadPicByCard":
                    string uploadPicByCard = SavePicToServer(context);
                    context.Response.Write(uploadPicByCard);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "学员功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #9
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;
                switch (action)
                {
                case "getall":
                    context.Response.Write(new ZGZY.BLL.Department().GetAllDepartment("1=1"));
                    break;

                case "search":
                    string strJson = new ZGZY.BLL.Department().GetAllDepartment(null);
                    context.Response.Write(strJson);
                    userOperateLog.OperateInfo = "查询部门";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:1=1";
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "searchDepartmentUser":
                    string userDepartmentIds       = context.Request.Params["departmentId"];
                    string sortDepartmentUser      = context.Request.Params["sort"];  //排序列
                    string orderDepartmentUser     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindexDepartmentUser = int.Parse(context.Request.Params["page"]);
                    int    pagesizeDepartmentUser  = int.Parse(context.Request.Params["rows"]);

                    string strJsonDepartmentUser = new ZGZY.BLL.Department().GetPagerDepartmentUser(userDepartmentIds, sortDepartmentUser + " " + orderDepartmentUser, pagesizeDepartmentUser, pageindexDepartmentUser);
                    context.Response.Write(strJsonDepartmentUser);
                    userOperateLog.OperateInfo = "查询部门用户";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询部门Id:" + userDepartmentIds + " 排序:" + sortDepartmentUser + " " + orderDepartmentUser + " 页码/每页大小:" + pageindexDepartmentUser + " " + pagesizeDepartmentUser;
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("department", "add", user.Id))
                    {
                        ZGZY.Model.Department departmentAdd = new Model.Department();
                        departmentAdd.DepartmentName = context.Request.Params["ui_department_departmentname_add"] ?? "";
                        departmentAdd.Sort           = Convert.ToInt32(context.Request.Params["ui_department_sort_add"]);
                        if (context.Request.Params["ui_department_parentid_add"] != null && context.Request.Params["ui_department_parentid_add"] != "")
                        {
                            departmentAdd.ParentId = Convert.ToInt32(context.Request.Params["ui_department_parentid_add"]);
                        }
                        else
                        {
                            departmentAdd.ParentId = 0;       //根节点
                        }
                        int departmentId = new ZGZY.BLL.Department().AddDepartment(departmentAdd);
                        if (departmentId > 0)
                        {
                            userOperateLog.OperateInfo = "添加部门";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,部门主键:" + departmentId;
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加部门";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加部门";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("department", "edit", user.Id))
                    {
                        ZGZY.Model.Department departmentEdit = new Model.Department();
                        departmentEdit.Id             = Convert.ToInt32(context.Request.Params["id"]);
                        departmentEdit.DepartmentName = context.Request.Params["ui_department_departmentname_edit"] ?? "";
                        departmentEdit.Sort           = Convert.ToInt32(context.Request.Params["ui_department_sort_edit"]);

                        bool result = new ZGZY.BLL.Department().EditDepartment(departmentEdit);
                        if (result)
                        {
                            userOperateLog.OperateInfo = "修改部门";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,部门主键:" + departmentEdit.Id;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改部门";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败,部门主键:" + departmentEdit.Id;
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改部门";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("department", "delete", user.Id))
                    {
                        string departmentIds = context.Request.Params["id"];
                        if (new ZGZY.BLL.Department().DeleteDepartment(departmentIds))
                        {
                            userOperateLog.OperateInfo = "删除部门";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,部门主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除部门";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败,部门主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除部门";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "部门功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #10
0
 /// <summary>
 /// 写入操作日志
 /// </summary>
 public static void InsertOperateInfo(Model.UserOperateLog userOperateLog)
 {
     dal.InsertOperateLog(userOperateLog);
 }
Пример #11
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_preAppointment_name      = context.Request.Params["ui_preAppointment_name"] ?? "";
                    string ui_preAppointment_code      = context.Request.Params["ui_preAppointment_code"] ?? "";
                    string ui_preAppointment_appstatus = context.Request.Params["ui_preAppointment_appstatus"] ?? "";

                    string subjectId = context.Request.Params["subjectId"] ?? "";

                    string ui_preAppointment_AppStartTime = context.Request.Params["ui_preAppointment_AppStartTime"] ?? "";
                    string ui_preAppointment_AppEndTime   = context.Request.Params["ui_preAppointment_AppEndTime"] ?? "";

                    strWhere += " and flag=1 and PeriodsID = (SELECT TOP 1 CurrentPeroidID FROM tb_CurrentPeroid)";
                    if (subjectId.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(subjectId))       //防止sql注入
                    {
                        strWhere += string.Format(" and SubjectID = '{0}'", subjectId.Trim());
                    }
                    if (ui_preAppointment_AppStartTime.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_preAppointment_AppStartTime))       //防止sql注入
                    {
                        strWhere += string.Format(" and AppointDate >= '{0}'", ui_preAppointment_AppStartTime.Trim());
                    }
                    if (ui_preAppointment_AppEndTime.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_preAppointment_AppEndTime))       //防止sql注入
                    {
                        strWhere += string.Format(" and AppointDate <= '{0}'", ui_preAppointment_AppEndTime.Trim());
                    }

                    if (ui_preAppointment_appstatus.Trim() != "select" && ui_preAppointment_appstatus.Trim() != "")
                    {
                        strWhere += " and AppointmentStatus = '" + ui_preAppointment_appstatus.Trim() + "'";
                    }

                    if (ui_preAppointment_name.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_preAppointment_name))       //防止sql注入
                    {
                        strWhere += string.Format(" and StudentsName like '%{0}%'", ui_preAppointment_name.Trim());
                    }
                    if (ui_preAppointment_code.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_preAppointment_code))
                    {
                        strWhere += string.Format(" and StudentCode like '%{0}%'", ui_preAppointment_code.Trim());
                    }


                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.AppointmentBLL().GetPager("V_PreAppointment", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询预约";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "appointment":      //预约考试
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("preAppointment", "preAppointment", userFromCookie.Id))
                    {
                        int      id = Convert.ToInt32(context.Request.Params["preAppointmentid_edit"]);
                        DateTime ui_preAppointment_appDate_edit = DateTime.Parse(context.Request.Params["ui_preAppointment_appDate_edit"] ?? "");
                        int      editsubjectId = Int32.Parse(context.Request.Params["subjectId"]);
                        string   ui_preAppointment_remark_edit = context.Request.Params["ui_preAppointment_remark_edit"] ?? "";

                        DriveMgr.Model.AppointmentModel appointmentEdit = new Model.AppointmentModel();
                        appointmentEdit.ID            = id;
                        appointmentEdit.AppointDate   = ui_preAppointment_appDate_edit;
                        appointmentEdit.Operater      = userFromCookie.UserName;
                        appointmentEdit.AppointStatus = 1;
                        appointmentEdit.SubjectID     = editsubjectId;
                        appointmentEdit.Remark        = ui_preAppointment_remark_edit;


                        if (new DriveMgr.BLL.AppointmentBLL().Update(appointmentEdit))
                        {
                            userOperateLog.OperateInfo = "预约考试信息";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "预约成功,预约主键:" + appointmentEdit.ID + ";预约科目:" + appointmentEdit.SubjectID;
                            context.Response.Write("{\"msg\":\"预约信息成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "预约考试信息";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "预约失败";
                            context.Response.Write("{\"msg\":\"预约失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "预约考试信息";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "预约考试功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #12
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_operatelog_username         = context.Request.Params["ui_operatelog_username"] ?? "";
                    string ui_operatelog_userip           = context.Request.Params["ui_operatelog_userip"] ?? "";
                    string ui_operatelog_info             = context.Request.Params["ui_operatelog_info"] ?? "";
                    string ui_operatelog_description      = context.Request.Params["ui_operatelog_description"] ?? "";
                    string ui_operatelog_success          = context.Request.Params["ui_operatelog_success"] ?? "";
                    string ui_operatelog_operatedatestart = context.Request.Params["ui_operatelog_operatedatestart"] ?? "";
                    string ui_operatelog_operatedateend   = context.Request.Params["ui_operatelog_operatedateend"] ?? "";

                    if (ui_operatelog_username.Trim() != "" && !ZGZY.Common.SqlInjection.GetString(ui_operatelog_username))       //防止sql注入
                    {
                        strWhere += string.Format(" and UserName like '%{0}%'", ui_operatelog_username.Trim());
                    }
                    if (ui_operatelog_userip.Trim() != "" && !ZGZY.Common.SqlInjection.GetString(ui_operatelog_userip))
                    {
                        strWhere += string.Format(" and UserIp like '%{0}%'", ui_operatelog_userip.Trim());
                    }
                    if (ui_operatelog_info.Trim() != "" && !ZGZY.Common.SqlInjection.GetString(ui_operatelog_info))
                    {
                        strWhere += string.Format(" and OperateInfo like '%{0}%'", ui_operatelog_info.Trim());
                    }
                    if (ui_operatelog_description.Trim() != "" && !ZGZY.Common.SqlInjection.GetString(ui_operatelog_description))
                    {
                        strWhere += string.Format(" and Description like '%{0}%'", ui_operatelog_description.Trim());
                    }
                    if (ui_operatelog_success.Trim() != "select" && ui_operatelog_success.Trim() != "")
                    {
                        strWhere += " and IfSuccess = '" + ui_operatelog_success.Trim() + "'";
                    }
                    if (ui_operatelog_operatedatestart.Trim() != "")
                    {
                        strWhere += " and OperateDate > '" + ui_operatelog_operatedatestart.Trim() + "'";
                    }
                    if (ui_operatelog_operatedateend.Trim() != "")
                    {
                        strWhere += " and OperateDate < '" + ui_operatelog_operatedateend.Trim() + "'";
                    }

                    userOperateLog.OperateInfo = "查询操作日志";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    //ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);

                    int    totalCount;    //输出参数
                    string strJson = new ZGZY.BLL.UserOperateLog().GetPager("tbUserOperateLog", "Id,UserName,UserIp,OperateInfo,Description,IfSuccess,OperateDate", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "操作日志功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                //ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #13
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "getbutton":                                            //根据用户的权限获取用户点击的菜单有权限的按钮
                    string    pageName = context.Request.Params["pagename"];
                    string    menuCode = context.Request.Params["menucode"]; //菜单标识码
                    DataTable dt       = new ZGZY.BLL.Customers().GetButtonByMenuCodeAndUserId(menuCode, user.Id);
                    string    sum      = ZGZY.Common.ToolbarHelper.GetToolBar(dt, pageName);
                    context.Response.Write(sum);
                    break;

                case "add":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("Channel", "add", user.Id))
                    {
                        ZGZY.Model.Channel channelAdd = new Model.Channel();
                        channelAdd.ChannelName = context.Request.Params["ui_Channel_ChannelName_add"];
                        channelAdd.Creator     = context.Request.Params["ui_Channel_Creator_add"];
                        channelAdd.BeginDate   = DateTime.Parse(context.Request.Params["ui_Channel_BeginDate_add"]);
                        channelAdd.EndDate     = DateTime.Parse(context.Request.Params["ui_Channel_EndDate_add"]);
                        channelAdd.CreateDate  = DateTime.Now;
                        channelAdd.SealNameId  = 72;



                        int departmentId = new ZGZY.BLL.Channel().AddChannel(channelAdd);
                        if (departmentId > 0)
                        {
                            userOperateLog.OperateInfo = "添加引用";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,客户主键:" + departmentId;
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加引用";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加引用";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;    //输出参数
                    string strJson = new ZGZY.BLL.Button().GetPager("Channel", "Id, ChannelName, CreateDate, Creator, SealNameId, BeginDate, EndDate", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询按钮";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("Channel", "edit", user.Id))
                    {
                        ZGZY.Model.Channel channelAdd = new Model.Channel();
                        channelAdd.Id          = Int32.Parse(context.Request.Params["id"]);
                        channelAdd.ChannelName = context.Request.Params["ui_Channel_ChannelName_edit"];
                        channelAdd.Creator     = context.Request.Params["ui_Channel_Creator_edit"];
                        channelAdd.BeginDate   = DateTime.Parse(context.Request.Params["ui_Channel_BeginDate_edit"]);
                        channelAdd.EndDate     = DateTime.Parse(context.Request.Params["ui_Channel_EndDate_edit"]);

                        int outputRow = new ZGZY.BLL.Channel().EditChannelById(channelAdd);
                        if (outputRow > 0)
                        {
                            userOperateLog.OperateInfo = "修改引用";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,客户主键:" + outputRow;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改引用";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改引用";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (user != null && new ZGZY.BLL.Authority().IfAuthority("Channel", "delete", user.Id))
                    {
                        object departmentIds = context.Request.Params["id"];
                        if (new ZGZY.BLL.Channel().DeleteChannelById(departmentIds) == 1)
                        {
                            userOperateLog.OperateInfo = "删除引用";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,引用主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除引用";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败,客户主键:" + departmentIds;
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除引用";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "菜单功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #14
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_examScores_stuname     = context.Request.Params["ui_examScores_stuname"] ?? "";
                    string ui_examScores_code        = context.Request.Params["ui_examScores_code"] ?? "";
                    string ui_examScores_subjectname = context.Request.Params["ui_examScores_subjectname"] ?? "";
                    string ui_examScores_examStatus  = context.Request.Params["ui_examScores_examStatus"] ?? "";

                    strWhere += " and flag=1 and PeriodsID = (SELECT TOP 1 CurrentPeroidID FROM tb_CurrentPeroid)";
                    if (ui_examScores_stuname.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_examScores_stuname))       //防止sql注入
                    {
                        strWhere += string.Format(" and StudentsName like '%{0}%'", ui_examScores_stuname.Trim());
                    }
                    if (ui_examScores_code.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_examScores_code))
                    {
                        strWhere += string.Format(" and StudentCode like '%{0}%'", ui_examScores_code.Trim());
                    }


                    if (ui_examScores_subjectname.Trim() != "" && ui_examScores_examStatus != "")
                    {
                        int ui_examScores_subjectid    = Int32.Parse(ui_examScores_subjectname);
                        int ui_examScores_examStatusId = Int32.Parse(ui_examScores_examStatus);
                        switch (ui_examScores_subjectid)
                        {
                        case 1:
                            strWhere += string.Format(" and OneStatus ={0}", ui_examScores_examStatusId);
                            break;

                        case 2:
                            strWhere += string.Format(" and TwoStatus ={0}", ui_examScores_examStatusId);
                            break;

                        case 3:
                            strWhere += string.Format(" and ThreeStatus ={0}", ui_examScores_examStatusId);
                            break;

                        case 4:
                            strWhere += string.Format(" and FourStatus ={0}", ui_examScores_examStatusId);
                            break;

                        default:
                            break;
                        }
                    }

                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.ScoresBLL().GetPager("V_ExamScores", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询成绩";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("examScores", "edit", userFromCookie.Id))
                    {
                        int     id = Convert.ToInt32(context.Request.Params["examScoresid_edit"]);
                        decimal ui_examScores_oneScore_edit    = Decimal.Parse(context.Request.Params["ui_examScores_oneScore_edit"] ?? "0");
                        int     ui_examScores_oneStatus_edit   = Int32.Parse(context.Request.Params["ui_examScores_oneStatus_edit"] ?? "-1");
                        decimal ui_examScores_twoScore_edit    = Decimal.Parse(context.Request.Params["ui_examScores_twoScore_edit"] ?? "0");
                        int     ui_examScores_twoStatus_edit   = Int32.Parse(context.Request.Params["ui_examScores_twoStatus_edit"] ?? "-1");
                        decimal ui_examScores_threeScore_edit  = Decimal.Parse(context.Request.Params["ui_examScores_threeScore_edit"] ?? "0");
                        int     ui_examScores_threeStatus_edit = Int32.Parse(context.Request.Params["ui_examScores_threeStatus_edit"] ?? "-1");
                        decimal ui_examScores_fourScore_edit   = Decimal.Parse(context.Request.Params["ui_examScores_fourScore_edit"] ?? "0");
                        int     ui_examScores_fourStatus_edit  = Int32.Parse(context.Request.Params["ui_examScores_fourStatus_edit"] ?? "-1");
                        string  ui_examScores_remark_edit      = context.Request.Params["ui_examScores_remark_edit"] ?? "";

                        DriveMgr.Model.ScoresModel scoresEdit = new Model.ScoresModel();
                        scoresEdit.ID        = id;
                        scoresEdit.ScoreOne  = ui_examScores_oneScore_edit;
                        scoresEdit.OneStatus = ui_examScores_oneStatus_edit;

                        scoresEdit.ScoreTwo  = ui_examScores_twoScore_edit;
                        scoresEdit.TwoStatus = ui_examScores_twoStatus_edit;

                        scoresEdit.SocreThree  = ui_examScores_threeScore_edit;
                        scoresEdit.ThreeStatus = ui_examScores_threeStatus_edit;

                        scoresEdit.ScoreFour  = ui_examScores_fourScore_edit;
                        scoresEdit.FourStatus = ui_examScores_fourStatus_edit;
                        scoresEdit.Remark     = ui_examScores_remark_edit;


                        if (new DriveMgr.BLL.ScoresBLL().Update(scoresEdit))
                        {
                            userOperateLog.OperateInfo = "修改成绩信息";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,成绩主键:" + scoresEdit.ID;
                            context.Response.Write("{\"msg\":\"修改成绩信息成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改成绩信息";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改成绩信息";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "成绩功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #15
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User user = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "getbutton":                                            //根据用户的权限获取用户点击的菜单有权限的按钮
                    string    pageName = context.Request.Params["pagename"];
                    string    menuCode = context.Request.Params["menucode"]; //菜单标识码
                    DataTable dt       = new DriveMgr.BLL.Button().GetButtonByMenuCodeAndUserId(menuCode, user.Id);
                    string    result   = DriveMgr.Common.ToolbarHelper.GetToolBar(dt, pageName);
                    context.Response.Write(result);
                    break;

                case "getAllButton":
                    string allresult = new DriveMgr.BLL.Button().GetAllButton();
                    context.Response.Write(allresult);
                    break;

                case "getButtonByMenu":
                    int    menuId       = Int32.Parse(context.Request.Params["menuId"]);
                    string byMenuresult = new DriveMgr.BLL.Button().GetButtonByMenu(menuId).ToJson();
                    context.Response.Write(byMenuresult);
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.Button().GetPager("tbButton", "Id,Name,Code,Icon,Sort,AddDate,Description", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询按钮";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("button", "add", user.Id))
                    {
                        string ui_button_buttonname_add  = context.Request.Params["ui_button_buttonname_add"] ?? "";
                        string ui_button_codename_add    = context.Request.Params["ui_button_codename_add"] ?? "";
                        string ui_button_iconname_add    = context.Request.Params["ui_button_iconname_add"] ?? "";
                        int    ui_button_sortname_add    = Int32.Parse(context.Request.Params["ui_button_sortname_add"]);
                        string ui_button_description_add = context.Request.Params["ui_button_description_add"] ?? "";

                        DriveMgr.Model.Button buttonAdd = new Model.Button();
                        buttonAdd.Name        = ui_button_buttonname_add.Trim();
                        buttonAdd.Code        = ui_button_codename_add.Trim();
                        buttonAdd.Icon        = ui_button_iconname_add.Trim();
                        buttonAdd.Sort        = ui_button_sortname_add;
                        buttonAdd.Description = ui_button_description_add.Trim();
                        buttonAdd.AddDate     = DateTime.Now;

                        bool buttonresult = new DriveMgr.BLL.Button().Add(buttonAdd);
                        if (buttonresult)
                        {
                            userOperateLog.OperateInfo = "添加按钮";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功";
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加按钮";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加按钮";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("button", "edit", user.Id))
                    {
                        int    id = Convert.ToInt32(context.Request.Params["id"]);
                        string ui_button_buttonname_edit  = context.Request.Params["ui_button_buttonname_edit"] ?? "";
                        string ui_button_codename_edit    = context.Request.Params["ui_button_codename_edit"] ?? "";
                        string ui_button_iconname_edit    = context.Request.Params["ui_button_iconname_edit"] ?? "";
                        int    ui_button_sortnname_edit   = Int32.Parse(context.Request.Params["ui_button_sortnname_edit"]);
                        string ui_button_description_edit = context.Request.Params["ui_button_description_edit"] ?? "";

                        DriveMgr.Model.Button buttonEdit = new Model.Button();
                        buttonEdit.Id          = id;
                        buttonEdit.Name        = ui_button_buttonname_edit.Trim();
                        buttonEdit.Code        = ui_button_codename_edit.Trim();
                        buttonEdit.Icon        = ui_button_iconname_edit.Trim();
                        buttonEdit.Sort        = ui_button_sortnname_edit;
                        buttonEdit.Description = ui_button_description_edit.Trim();
                        buttonEdit.AddDate     = DateTime.Now;

                        if (new DriveMgr.BLL.Button().Update(buttonEdit))
                        {
                            userOperateLog.OperateInfo = "修改按钮";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,按钮主键:" + buttonEdit.Id;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改按钮";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改按钮";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("button", "delete", user.Id))
                    {
                        string ids = context.Request.Params["id"].Trim(',');
                        if (new DriveMgr.BLL.Button().DeleteList(ids))
                        {
                            userOperateLog.OperateInfo = "删除按钮";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,按钮主键:" + ids;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除按钮";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败";
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除按钮";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "按钮功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #16
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "firstlogin":
                    int    ui_user_firstlogin_id  = Convert.ToInt32(context.Request.Params["ui_user_firstlogin_id"]);
                    string ui_user_firstlogin_pwd = context.Request.Params["ui_user_firstlogin_pwd"] ?? "";
                    if (userFromCookie != null && userFromCookie.Id == ui_user_firstlogin_id)       //只能修改当前登录的用户
                    {
                        DriveMgr.Model.User initUser = new Model.User();
                        initUser.Id      = ui_user_firstlogin_id;
                        initUser.UserPwd = DriveMgr.Common.Md5.GetMD5String(ui_user_firstlogin_pwd);       //加密
                        if (initUser.UserPwd != userFromCookie.UserPwd)
                        {
                            if (new DriveMgr.BLL.User().InitUserPwd(initUser))
                            {
                                //修改成功需要重写cookie,否则cookie里的密码不对下次经过bg_user_login.asxh里的getuser语句块就自动退出了
                                FormsIdentity             id        = (FormsIdentity)context.User.Identity;
                                FormsAuthenticationTicket ticketOld = id.Ticket;
                                userFromCookie.UserPwd = initUser.UserPwd;       //赋值新密码,其他属性不变

                                FormsAuthentication.SignOut();
                                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket
                                                                   (
                                    2,
                                    userFromCookie.UserId,
                                    DateTime.Now,
                                    ticketOld.Expiration,
                                    false,
                                    new JavaScriptSerializer().Serialize(userFromCookie)      //序列化新的用户对象
                                                                   );
                                string     encTicket = FormsAuthentication.Encrypt(ticket);
                                HttpCookie cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
                                if (ticket.Expiration != new DateTime(9999, 12, 31))        //不是默认时间才设置过期时间,否则会话cookie
                                {
                                    cookie.Expires = ticketOld.Expiration;
                                }
                                context.Response.Cookies.Add(cookie);

                                userOperateLog.OperateInfo = "用户重置密码";
                                userOperateLog.IfSuccess   = true;
                                userOperateLog.Description = "重置密码成功";
                                context.Response.Write("{\"msg\":\"重置密码成功!\",\"success\":true}");
                            }
                            else
                            {
                                userOperateLog.OperateInfo = "用户重置密码";
                                userOperateLog.IfSuccess   = false;
                                userOperateLog.Description = "重置密码失败";
                                context.Response.Write("{\"msg\":\"重置密码失败!\",\"success\":false}");
                            }
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "用户重置密码";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "重置密码失败,不能和默认密码一样";
                            context.Response.Write("{\"msg\":\"重置密码失败,不能和默认密码一样!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "用户重置密码";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "未知错误,重置密码失败";
                        context.Response.Write("{\"msg\":\"未知错误,重置密码失败!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "changepwd":
                    string ui_user_userchangepwd_originalpwd = context.Request.Params["ui_user_userchangepwd_originalpwd"] ?? "";
                    string ui_user_userchangepwd_newpwd      = context.Request.Params["ui_user_userchangepwd_newpwd"] ?? "";

                    DriveMgr.Model.User userChangePwd = new Model.User();
                    userChangePwd.Id      = userFromCookie.Id;
                    userChangePwd.UserPwd = DriveMgr.Common.Md5.GetMD5String(ui_user_userchangepwd_newpwd);       //md5加密

                    if (DriveMgr.Common.Md5.GetMD5String(ui_user_userchangepwd_originalpwd) == userFromCookie.UserPwd)
                    {
                        if (new DriveMgr.BLL.User().ChangePwd(userChangePwd))
                        {
                            FormsAuthentication.SignOut();        //这里如果不退出还得重写cookie
                            userOperateLog.OperateInfo = "用户修改密码";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,用户主键:" + userChangePwd.Id;
                            context.Response.Write("{\"msg\":\"修改成功,正在跳转到登陆页面!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "用户修改密码";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "用户修改密码";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "原密码不正确";
                        context.Response.Write("{\"msg\":\"原密码不正确!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "getUserInfo":
                    context.Response.Write(new DriveMgr.BLL.User().GetUserInfo(userFromCookie.Id));       //“我的信息”
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_user_userid       = context.Request.Params["ui_user_userid"] ?? "";
                    string ui_user_username     = context.Request.Params["ui_user_username"] ?? "";
                    string ui_user_isable       = context.Request.Params["ui_user_isable"] ?? "";
                    string ui_user_ifchangepwd  = context.Request.Params["ui_user_ifchangepwd"] ?? "";
                    string ui_user_description  = context.Request.Params["ui_user_description"] ?? "";
                    string ui_user_adddatestart = context.Request.Params["ui_user_adddatestart"] ?? "";
                    string ui_user_adddateend   = context.Request.Params["ui_user_adddateend"] ?? "";

                    if (ui_user_userid.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_user_userid))       //防止sql注入
                    {
                        strWhere += string.Format(" and UserId like '%{0}%'", ui_user_userid.Trim());
                    }
                    if (ui_user_username.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_user_username))
                    {
                        strWhere += string.Format(" and UserName like '%{0}%'", ui_user_username.Trim());
                    }
                    if (ui_user_description.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_user_description))
                    {
                        strWhere += string.Format(" and Description like '%{0}%'", ui_user_description.Trim());
                    }
                    if (ui_user_isable.Trim() != "select" && ui_user_isable.Trim() != "")
                    {
                        strWhere += " and IsAble = '" + ui_user_isable.Trim() + "'";
                    }
                    if (ui_user_ifchangepwd.Trim() != "select" && ui_user_ifchangepwd.Trim() != "")
                    {
                        strWhere += " and IfChangePwd = '" + ui_user_ifchangepwd.Trim() + "'";
                    }
                    if (ui_user_adddatestart.Trim() != "")
                    {
                        strWhere += " and AddDate > '" + ui_user_adddatestart.Trim() + "'";
                    }
                    if (ui_user_adddateend.Trim() != "")
                    {
                        strWhere += " and AddDate < '" + ui_user_adddateend.Trim() + "'";
                    }

                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.User().GetPager("tbUser", "Id,UserId,UserName,IsAble,IfChangePwd,AddDate,Description", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询用户";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("user", "add", userFromCookie.Id))
                    {
                        string ui_user_userid_add      = context.Request.Params["ui_user_userid_add"] ?? "";
                        string ui_user_username_add    = context.Request.Params["ui_user_username_add"] ?? "";
                        bool   ui_user_isable_add      = context.Request.Params["ui_user_isable_add"] == null ? false : true;
                        bool   ui_user_ifchangepwd_add = context.Request.Params["ui_user_ifchangepwd_add"] == null ? false : true;
                        string ui_user_description_add = context.Request.Params["ui_user_description_add"] ?? "";

                        DriveMgr.Model.User userAdd = new Model.User();
                        userAdd.UserId      = ui_user_userid_add.Trim();
                        userAdd.UserName    = ui_user_username_add.Trim();
                        userAdd.UserPwd     = DriveMgr.Common.Md5.GetMD5String("123");   //md5加密
                        userAdd.IsAble      = ui_user_isable_add;
                        userAdd.IfChangePwd = ui_user_ifchangepwd_add;
                        userAdd.Description = ui_user_description_add.Trim();

                        int userId = new DriveMgr.BLL.User().AddUser(userAdd);
                        if (userId > 0)
                        {
                            userOperateLog.OperateInfo = "添加用户";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,用户主键:" + userId;
                            context.Response.Write("{\"msg\":\"添加成功!默认密码是【123】\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加用户";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加用户";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("user", "edit", userFromCookie.Id))
                    {
                        int    id                       = Convert.ToInt32(context.Request.Params["id"]);
                        string originalName             = context.Request.Params["originalName"] ?? "";
                        string ui_user_userid_edit      = context.Request.Params["ui_user_userid_edit"] ?? "";
                        string ui_user_username_edit    = context.Request.Params["ui_user_username_edit"] ?? "";
                        bool   ui_user_isable_edit      = context.Request.Params["ui_user_isable_edit"] == null ? false : true;
                        bool   ui_user_ifchangepwd_edit = context.Request.Params["ui_user_ifchangepwd_edit"] == null ? false : true;
                        string ui_user_description_edit = context.Request.Params["ui_user_description_edit"] ?? "";

                        DriveMgr.Model.User userEdit = new Model.User();
                        userEdit.Id          = id;
                        userEdit.UserId      = ui_user_userid_edit.Trim();
                        userEdit.UserName    = ui_user_username_edit.Trim();
                        userEdit.IsAble      = ui_user_isable_edit;
                        userEdit.IfChangePwd = ui_user_ifchangepwd_edit;
                        userEdit.Description = ui_user_description_edit.Trim();

                        if (new DriveMgr.BLL.User().EditUser(userEdit, originalName))
                        {
                            userOperateLog.OperateInfo = "修改用户";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,用户主键:" + userEdit.Id;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改用户";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改用户";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("user", "delete", userFromCookie.Id))
                    {
                        string ids = context.Request.Params["id"].Trim(',');
                        if (new DriveMgr.BLL.User().DeleteUser(ids))
                        {
                            userOperateLog.OperateInfo = "删除用户";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,用户主键:" + ids;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除用户";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败";
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除用户";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "setdep":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("user", "setdepartment", userFromCookie.Id))
                    {
                        string ui_user_setdep_userid = context.Request.Params["ui_user_setdep_userid"] ?? "";
                        string ui_user_setdep_dep    = context.Request.Params["ui_user_setdep_dep"] ?? "";

                        if (ui_user_setdep_userid.IndexOf(",") == -1)      //单个用户设置部门
                        {
                            if (ui_user_setdep_userid != "" && new BLL.UserDepartment().SetDepartmentSingle(Convert.ToInt32(ui_user_setdep_userid), ui_user_setdep_dep))
                            {
                                userOperateLog.OperateInfo = "设置用户部门";
                                userOperateLog.IfSuccess   = true;
                                userOperateLog.Description = "设置成功,用户主键:" + ui_user_setdep_userid + " 部门主键:" + ui_user_setdep_dep;
                                context.Response.Write("{\"msg\":\"设置成功!\",\"success\":true}");
                            }
                            else
                            {
                                userOperateLog.OperateInfo = "设置用户部门";
                                userOperateLog.IfSuccess   = false;
                                userOperateLog.Description = "设置失败,用户主键:" + ui_user_setdep_userid + " 部门主键:" + ui_user_setdep_dep;
                                context.Response.Write("{\"msg\":\"设置失败!\",\"success\":true}");
                            }
                        }
                        else       //批量设置用户部门
                        {
                            if (ui_user_setdep_userid != "" && new BLL.UserDepartment().SetDepartmentBatch(ui_user_setdep_userid, ui_user_setdep_dep))
                            {
                                userOperateLog.OperateInfo = "批量设置用户部门";
                                userOperateLog.IfSuccess   = true;
                                userOperateLog.Description = "设置成功,用户主键:" + ui_user_setdep_userid + " 部门主键:" + ui_user_setdep_dep;
                                context.Response.Write("{\"msg\":\"设置成功!\",\"success\":true}");
                            }
                            else
                            {
                                userOperateLog.OperateInfo = "批量设置用户部门";
                                userOperateLog.IfSuccess   = false;
                                userOperateLog.Description = "设置失败,用户主键:" + ui_user_setdep_userid + " 部门主键:" + ui_user_setdep_dep;
                                context.Response.Write("{\"msg\":\"设置失败!\",\"success\":true}");
                            }
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "设置用户部门";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "setrole":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("user", "setrole", userFromCookie.Id))
                    {
                        string ui_user_setrole_userid = context.Request.Params["ui_user_setrole_userid"] ?? ""; //用户id,可能是多个
                        string ui_user_setrole_role   = context.Request.Params["ui_user_setrole_role"] ?? "";   //角色id,可能是多个

                        if (ui_user_setrole_userid.IndexOf(",") == -1)                                          //单个用户分配角色
                        {
                            if (ui_user_setrole_userid != "" && new BLL.UserRole().SetRoleSingle(Convert.ToInt32(ui_user_setrole_userid), ui_user_setrole_role))
                            {
                                userOperateLog.OperateInfo = "设置用户角色";
                                userOperateLog.IfSuccess   = true;
                                userOperateLog.Description = "设置成功,用户主键:" + ui_user_setrole_userid + " 角色主键:" + ui_user_setrole_role;
                                context.Response.Write("{\"msg\":\"设置成功!\",\"success\":true}");
                            }
                            else
                            {
                                userOperateLog.OperateInfo = "设置用户角色";
                                userOperateLog.IfSuccess   = false;
                                userOperateLog.Description = "设置失败,用户主键:" + ui_user_setrole_userid + " 角色主键:" + ui_user_setrole_role;
                                context.Response.Write("{\"msg\":\"设置失败!\",\"success\":true}");
                            }
                        }
                        else       //批量设置用户角色
                        {
                            if (ui_user_setrole_userid != "" && new BLL.UserRole().SetRoleBatch(ui_user_setrole_userid, ui_user_setrole_role))
                            {
                                userOperateLog.OperateInfo = "批量设置用户角色";
                                userOperateLog.IfSuccess   = true;
                                userOperateLog.Description = "设置成功,用户主键:" + ui_user_setrole_userid + " 角色主键:" + ui_user_setrole_role;
                                context.Response.Write("{\"msg\":\"设置成功!\",\"success\":true}");
                            }
                            else
                            {
                                userOperateLog.OperateInfo = "批量设置用户角色";
                                userOperateLog.IfSuccess   = false;
                                userOperateLog.Description = "设置失败,用户主键:" + ui_user_setrole_userid + " 角色主键:" + ui_user_setrole_role;
                                context.Response.Write("{\"msg\":\"设置失败!\",\"success\":true}");
                            }
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "设置用户角色";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "用户功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);


                    string ui_peroid_setup_code = context.Request.Params["ui_peroid_setup_code"] ?? "";

                    strWhere += " and flag=1";
                    if (ui_peroid_setup_code.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_peroid_setup_code))       //防止sql注入
                    {
                        strWhere += string.Format(" and PeriodCode like '%{0}%'", ui_peroid_setup_code.Trim());
                    }


                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.PeriodsBLL().GetPager("V_PeroidsAndCurrent", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询期数";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("peroid_setup", "add", userFromCookie.Id))
                    {
                        string ui_peroid_setup_code_add   = context.Request.Params["ui_peroid_setup_code_add"] ?? "";
                        string ui_peroid_setup_remark_add = context.Request.Params["ui_peroid_setup_remark_add"] ?? "";

                        DriveMgr.Model.PeriodsModel periodsAdd = new Model.PeriodsModel();
                        periodsAdd.PeriodCode = ui_peroid_setup_code_add;
                        periodsAdd.Remark     = ui_peroid_setup_remark_add;

                        bool result = new DriveMgr.BLL.PeriodsBLL().Add(periodsAdd);
                        if (result)
                        {
                            userOperateLog.OperateInfo = "添加期数";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加期数,期数" + ui_peroid_setup_code_add;
                            context.Response.Write("{\"msg\":\"添加期数成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加期数";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加期数";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("peroid_setup", "edit", userFromCookie.Id))
                    {
                        int    id = Convert.ToInt32(context.Request.Params["id_peroid_setup"]);
                        string ui_peroid_setup_code_edit   = context.Request.Params["ui_peroid_setup_code_edit"] ?? "";
                        string ui_peroid_setup_remark_edit = context.Request.Params["ui_peroid_setup_remark_edit"] ?? "";

                        DriveMgr.Model.PeriodsModel periodsEdit = new Model.PeriodsModel();
                        periodsEdit.PeriodCode = ui_peroid_setup_code_edit;
                        periodsEdit.Remark     = ui_peroid_setup_remark_edit;
                        periodsEdit.ID         = id;

                        if (new DriveMgr.BLL.PeriodsBLL().Update(periodsEdit))
                        {
                            userOperateLog.OperateInfo = "修改期数";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,期数主键:" + periodsEdit.ID;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改期数";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改期数";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("peroid_setup", "delete", userFromCookie.Id))
                    {
                        string ids = context.Request.Params["id"].Trim(',');
                        if (new DriveMgr.BLL.PeriodsBLL().DeleteList(ids))
                        {
                            userOperateLog.OperateInfo = "删除期数";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,期数主键:" + ids;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除期数";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败";
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除期数";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "setupnew":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("peroid_setup", "setupnew", userFromCookie.Id))
                    {
                        int id = Convert.ToInt32(context.Request.Params["currentid_peroid_setup"]);
                        if (new DriveMgr.BLL.PeriodsBLL().SetupToCurrent(id))
                        {
                            userOperateLog.OperateInfo = "设置期数为当前期数";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "设置成功,期数主键:" + id;
                            context.Response.Write("{\"msg\":\"设置成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "设置期数为当前期数";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "设置失败";
                            context.Response.Write("{\"msg\":\"设置失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "设置期数为当前期数";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "期数功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User user = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;

                switch (action)
                {
                case "getUserMenu":      //获取特定用户能看到的菜单(左侧树)
                    context.Response.Write(new DriveMgr.BLL.Menu().GetUserMenu(user.Id));
                    break;

                case "getAllMenu":                                                  //根据角色id获取此角色有的权限(设置角色时自动勾选已经有的按钮权限)
                    int roleid = Convert.ToInt32(context.Request.Params["roleid"]); //角色id
                    context.Response.Write(new DriveMgr.BLL.Menu().GetAllMenu(roleid));
                    break;

                case "getMyAuthority":      //前台根据用户名查“我的权限”
                    context.Response.Write(new DriveMgr.BLL.Menu().GetMyAuthority(user.Id));
                    userOperateLog.OperateInfo = "查询我的信息";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询我的信息";
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "search":
                    string strWhere  = "1=1 ";
                    string sort      = context.Request.Params["sort"] == null ? "Id" : context.Request.Params["sort"];    //排序列
                    string order     = context.Request.Params["order"] == null ? "asc" : context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;            //输出参数
                    string strJson = "";          //输出结果
                    if (order.IndexOf(',') != -1) //如果有","就是多列排序(不能拿列判断,列名中间可能有","符号)
                    {
                        //多列排序:
                        //sort:ParentId,Sort,AddDate
                        //order:asc,desc,asc
                        string   sortMulti  = "";              //拼接排序条件,例:ParentId desc,Sort asc
                        string[] sortArray  = sort.Split(','); //列名中间有","符号,这里也要出错。正常不会有
                        string[] orderArray = order.Split(',');
                        for (int i = 0; i < sortArray.Length; i++)
                        {
                            sortMulti += sortArray[i] + " " + orderArray[i] + ",";
                        }
                        strJson = new DriveMgr.BLL.Menu().GetPager("tbMenu", "Id,Name,ParentId,Code,LinkAddress,Icon,Sort,AddDate", sortMulti.Trim(','), pagesize, pageindex, strWhere, out totalCount);
                        userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sortMulti.Trim(',') + " 页码/每页大小:" + pageindex + " " + pagesize;
                    }
                    else
                    {
                        strJson = new DriveMgr.BLL.Menu().GetPager("tbMenu", "Id,Name,ParentId,Code,LinkAddress,Icon,Sort,AddDate", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                        userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    }

                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询菜单";
                    userOperateLog.IfSuccess   = true;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "bindFatherMenu":
                    string strResult = new DriveMgr.BLL.Menu().GetAllMenuByCondition("1=1");
                    context.Response.Write(strResult);
                    break;

                case "add":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("menu", "add", user.Id))
                    {
                        DriveMgr.Model.Menu menuAdd = new Model.Menu();
                        menuAdd.Id          = Convert.ToInt32(context.Request.Params["id"]);
                        menuAdd.Name        = context.Request.Params["ui_menu_menuname_add"] ?? "";
                        menuAdd.Code        = context.Request.Params["ui_menu_codename_add"] ?? "";
                        menuAdd.LinkAddress = context.Request.Params["ui_menu_link_add"] ?? "";
                        menuAdd.Icon        = context.Request.Params["ui_menu_iconname_add"] ?? "";
                        menuAdd.Sort        = Convert.ToInt32(context.Request.Params["ui_menu_sortname_add"]);
                        menuAdd.AddDate     = DateTime.Now;

                        if (context.Request.Params["ui_menu_fathermenuname_add"] != null && context.Request.Params["ui_menu_fathermenuname_add"] != "")
                        {
                            menuAdd.ParentId = Convert.ToInt32(context.Request.Params["ui_menu_fathermenuname_add"]);
                        }
                        else
                        {
                            menuAdd.ParentId = 0;       //根节点
                        }
                        bool menuResult = new DriveMgr.BLL.Menu().Add(menuAdd);
                        if (menuResult)
                        {
                            userOperateLog.OperateInfo = "添加菜单";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功";
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加菜单";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加菜单";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":true}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("menu", "edit", user.Id))
                    {
                        DriveMgr.Model.Menu menuEdit = new Model.Menu();
                        menuEdit.Id          = Convert.ToInt32(context.Request.Params["id"]);
                        menuEdit.Name        = context.Request.Params["ui_menu_menuname_edit"] ?? "";
                        menuEdit.Code        = context.Request.Params["ui_menu_codename_edit"] ?? "";
                        menuEdit.LinkAddress = context.Request.Params["ui_menu_link_edit"] ?? "";
                        menuEdit.Icon        = context.Request.Params["ui_menu_iconname_edit"] ?? "";
                        menuEdit.Sort        = Convert.ToInt32(context.Request.Params["ui_menu_sortname_edit"]);
                        menuEdit.AddDate     = DateTime.Now;

                        bool result = new DriveMgr.BLL.Menu().Update(menuEdit);
                        if (result)
                        {
                            userOperateLog.OperateInfo = "修改菜单";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,菜单主键:" + menuEdit.Id;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改菜单";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败,菜单主键:" + menuEdit.Id;
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改菜单";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("menu", "delete", user.Id))
                    {
                        string menuIds = context.Request.Params["id"].Trim(',');
                        if (new DriveMgr.BLL.Menu().DeleteList(menuIds))
                        {
                            userOperateLog.OperateInfo = "删除菜单";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,菜单主键:" + menuIds;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除菜单";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败,菜单主键:" + menuIds;
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除菜单";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "distribute":
                    if (user != null && new DriveMgr.BLL.Authority().IfAuthority("menu", "setbutton", user.Id))
                    {
                        string menuButtonId = context.Request.Params["menuButtonId"].Trim(','); //具体的菜单和按钮权限
                        int    menuId       = Int32.Parse(context.Request.Params["menuId"]);    //具体的菜单和按钮权限
                        if (new DriveMgr.BLL.MenuButton().Add(menuId, menuButtonId))
                        {
                            userOperateLog.OperateInfo = "分配按钮";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "分配按钮,菜单/按钮Id:" + menuButtonId;
                            context.Response.Write("{\"msg\":\"分配按钮成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "分配按钮";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "分配失败";
                            context.Response.Write("{\"msg\":\"分配失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "分配按钮";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "菜单功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_distributeVehicle_name    = context.Request.Params["ui_distributeVehicle_name"] ?? "";
                    string ui_distributeVehicle_code    = context.Request.Params["ui_distributeVehicle_code"] ?? "";
                    string ui_distributeVehicle_vehicle = context.Request.Params["ui_distributeVehicle_vehicle"] ?? "";

                    string subjectID = context.Request.Params["subject"] ?? "";

                    strWhere += " and flag=1 and PeriodsID = (SELECT TOP 1 CurrentPeroidID FROM tb_CurrentPeroid)";
                    if (subjectID.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(subjectID))       //防止sql注入
                    {
                        strWhere += string.Format(" and SubjectID = '{0}'", subjectID.Trim());
                    }
                    if (ui_distributeVehicle_name.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_distributeVehicle_name))       //防止sql注入
                    {
                        strWhere += string.Format(" and StudentsName like '%{0}%'", ui_distributeVehicle_name.Trim());
                    }
                    if (ui_distributeVehicle_code.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_distributeVehicle_code))
                    {
                        strWhere += string.Format(" and StudentCode like '%{0}%'", ui_distributeVehicle_code.Trim());
                    }
                    if (ui_distributeVehicle_vehicle.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_distributeVehicle_vehicle))
                    {
                        strWhere += string.Format(" and VehicleID={0}", ui_distributeVehicle_vehicle.Trim());
                    }



                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.ScoresBLL().GetPager("V_DistributeVehicle", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询分配车辆";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "autoDistributeVehicle":     //自动分配车辆
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("distributeVehicle", "autoDistributeVehicle", userFromCookie.Id))
                    {
                        int    subjectId         = Int32.Parse(context.Request.Params["subject"]);
                        string distributeVehicle = new DriveMgr.BLL.VehicleBLL().AddDistributeVehicle(subjectId, userFromCookie.UserName);
                        userOperateLog.OperateInfo = "科目" + subjectId + "自动分配车辆";
                        userOperateLog.IfSuccess   = true;
                        userOperateLog.Description = distributeVehicle;

                        context.Response.Write("{\"msg\":\"" + distributeVehicle + "\",\"success\":true}");
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "自动分配车辆";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("distributeVehicle", "edit", userFromCookie.Id))
                    {
                        int id = Convert.ToInt32(context.Request.Params["ui_distributeVehicleid_edit"]);
                        int ui_distributeVehicle_vehicle_edit = Int32.Parse(context.Request.Params["ui_distributeVehicle_vehicle_edit"] ?? "0");
                        int subjectId = Int32.Parse(context.Request.Params["subject"]);

                        DriveMgr.Model.DistributionVehicleModel distributeVehicleEdit = new Model.DistributionVehicleModel();
                        distributeVehicleEdit.ID         = id;
                        distributeVehicleEdit.VehicleID  = ui_distributeVehicle_vehicle_edit;
                        distributeVehicleEdit.SubjectID  = subjectId;
                        distributeVehicleEdit.CreateTime = DateTime.Now;
                        distributeVehicleEdit.Operater   = userFromCookie.UserName;
                        distributeVehicleEdit.DistributeVihicleStatus = 1;     //已分配


                        if (new DriveMgr.BLL.VehicleBLL().EditDistributeStudents(distributeVehicleEdit))
                        {
                            userOperateLog.OperateInfo = "修改分配车辆信息";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,分配车辆主键:" + distributeVehicleEdit.ID;
                            context.Response.Write("{\"msg\":\"修改分配车辆信息成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改分配车辆信息";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改分配车辆信息";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "分配车辆功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #20
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            ZGZY.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                ZGZY.Model.User user = ZGZY.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = user.UserId;
                int menuid = Convert.ToInt32(context.Request.Params["menuid"]);
                switch (action)
                {
                case "getUserMenu":      //获取特定用户能看到的菜单(左侧树)
                    int mainMenuId = Convert.ToInt32(context.Request.Params["mainMenuId"]);
                    context.Response.Write(new ZGZY.BLL.Menu().GetUserMenu(user.Id, mainMenuId));
                    break;

                case "getAllMenu":                                                  //根据角色id获取此角色有的权限(设置角色时自动勾选已经有的按钮权限)
                    int roleid = Convert.ToInt32(context.Request.Params["roleid"]); //角色id
                    context.Response.Write(new ZGZY.BLL.Menu().GetAllMenu(roleid));
                    break;

                case "getMyAuthority":      //前台根据用户名查“我的权限”
                    context.Response.Write(new ZGZY.BLL.Menu().GetMyAuthority(user.Id));
                    userOperateLog.OperateInfo = "查询我的信息";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询我的信息";
                    //ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"] == null ? "Id" : context.Request.Params["sort"];    //排序列
                    string order     = context.Request.Params["order"] == null ? "asc" : context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    int    totalCount;            //输出参数
                    string strJson = "";          //输出结果
                    if (order.IndexOf(',') != -1) //如果有","就是多列排序(不能拿列判断,列名中间可能有","符号)
                    {
                        //多列排序:
                        //sort:ParentId,Sort,AddDate
                        //order:asc,desc,asc
                        string   sortMulti  = "";              //拼接排序条件,例:ParentId desc,Sort asc
                        string[] sortArray  = sort.Split(','); //列名中间有","符号,这里也要出错。正常不会有
                        string[] orderArray = order.Split(',');
                        for (int i = 0; i < sortArray.Length; i++)
                        {
                            sortMulti += sortArray[i] + " " + orderArray[i] + ",";
                        }
                        strJson = new ZGZY.BLL.Menu().GetPager("tbMenu", "Id,Name,ParentId,Code,LinkAddress,Icon,Sort,AddDate", sortMulti.Trim(','), pagesize, pageindex, strWhere, out totalCount);
                        userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sortMulti.Trim(',') + " 页码/每页大小:" + pageindex + " " + pagesize;
                    }
                    else
                    {
                        strJson = new ZGZY.BLL.Menu().GetPager("tbMenu", "Id,Name,ParentId,Code,LinkAddress,Icon,Sort,AddDate", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                        userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    }

                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");
                    userOperateLog.OperateInfo = "查询菜单";
                    userOperateLog.IfSuccess   = true;
                    //ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "getMenuButton":
                    context.Response.Write(new ZGZY.BLL.Menu().GetMenuButton(menuid));
                    break;

                case "setMenuButton":
                    string ui_menu_setbutton_menuid = context.Request.Params["ui_menu_setbutton_menuid"] ?? "";
                    string ui_menu_setbutton_button = context.Request.Params["ui_menu_setbutton_button"] ?? "";
                    if (ui_menu_setbutton_menuid != "" && new BLL.Menu().SetMenuButton(ui_menu_setbutton_menuid, ui_menu_setbutton_button))
                    {
                        context.Response.Write("{\"msg\":\"分配成功!\",\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"msg\":\"分配失败!\",\"success\":false}");
                    }
                    break;

                case "getMainMenu":
                    context.Response.Write(new ZGZY.BLL.Menu().GetMainMenu(1));
                    break;

                case "getBelongMainMenu":
                    string belongMainMenuId = new ZGZY.BLL.Menu().GetBelongMainMenuId(menuid);
                    context.Response.Write("{\"mainMenuId\":\"" + belongMainMenuId + "\"}");
                    break;

                case "setMainMenu":
                    string ui_menu_setMainMenu_menuid = context.Request.Params["ui_menu_setMainMenu_menuid"] ?? "";
                    string ui_menu_setMainMenu_button = context.Request.Params["ui_menu_setMainMenu_button"] ?? "";
                    if (ui_menu_setMainMenu_menuid != "" && new BLL.Menu().SetMainMenu(ui_menu_setMainMenu_menuid, ui_menu_setMainMenu_button))
                    {
                        context.Response.Write("{\"msg\":\"配置成功!\",\"success\":true}");
                    }
                    else
                    {
                        context.Response.Write("{\"msg\":\"配置失败!\",\"success\":false}");
                    }
                    break;

                default:
                    context.Response.Write("{\"result\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + ZGZY.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "菜单功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = ZGZY.Common.JsonHelper.StringFilter(ex.Message);
                //ZGZY.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }
Пример #21
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string action = context.Request.Params["action"];

            DriveMgr.Model.UserOperateLog userOperateLog = null;   //操作日志对象
            try
            {
                DriveMgr.Model.User userFromCookie = DriveMgr.Common.UserHelper.GetUser(context);   //获取cookie里的用户对象
                userOperateLog          = new Model.UserOperateLog();
                userOperateLog.UserIp   = context.Request.UserHostAddress;
                userOperateLog.UserName = userFromCookie.UserId;
                switch (action)
                {
                case "search":
                    string strWhere  = "1=1";
                    string sort      = context.Request.Params["sort"];  //排序列
                    string order     = context.Request.Params["order"]; //排序方式 asc或者desc
                    int    pageindex = int.Parse(context.Request.Params["page"]);
                    int    pagesize  = int.Parse(context.Request.Params["rows"]);

                    string ui_coach_name     = context.Request.Params["ui_coach_name"] ?? "";
                    string ui_coach_address  = context.Request.Params["ui_coach_address"] ?? "";
                    string ui_coach_phonenum = context.Request.Params["ui_coach_phonenum"] ?? "";

                    strWhere += " and CoachStatus = 1";
                    if (ui_coach_name.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_coach_name))       //防止sql注入
                    {
                        strWhere += string.Format(" and CoachName like '%{0}%'", ui_coach_name.Trim());
                    }
                    if (ui_coach_address.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_coach_address))
                    {
                        strWhere += string.Format(" and Address like '%{0}%'", ui_coach_address.Trim());
                    }
                    if (ui_coach_phonenum.Trim() != "" && !DriveMgr.Common.SqlInjection.GetString(ui_coach_phonenum))
                    {
                        strWhere += string.Format(" and CardNum like '%{0}%'", ui_coach_phonenum.Trim());
                    }

                    int    totalCount;    //输出参数
                    string strJson = new DriveMgr.BLL.CoachBLL().GetPager("tb_Coach", "*", sort + " " + order, pagesize, pageindex, strWhere, out totalCount);
                    context.Response.Write("{\"total\": " + totalCount.ToString() + ",\"rows\":" + strJson + "}");

                    userOperateLog.OperateInfo = "查询教练信息";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询条件:" + strWhere + " 排序:" + sort + " " + order + " 页码/每页大小:" + pageindex + " " + pagesize;
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "add":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("coach", "add", userFromCookie.Id))
                    {
                        string ui_coach_name_add     = context.Request.Params["ui_coach_name_add"] ?? "";
                        string ui_coach_cardnum_add  = context.Request.Params["ui_coach_cardnum_add"] ?? "";
                        int    ui_coach_age_add      = Int32.Parse(context.Request.Params["ui_coach_age_add"] ?? "-1");
                        bool   ui_coach_sex_add      = context.Request.Params["ui_coach_sex_add"] == "0" ? false : true;
                        string ui_coach_phonenum_add = context.Request.Params["ui_coach_phonenum_add"] ?? "";
                        string ui_coach_address_add  = context.Request.Params["ui_coach_address_add"] ?? "";

                        DriveMgr.Model.CoachModel coachAdd = new Model.CoachModel();
                        coachAdd.CoachName = ui_coach_name_add.Trim();
                        coachAdd.CardNum   = ui_coach_cardnum_add.Trim();
                        coachAdd.Age       = ui_coach_age_add;
                        coachAdd.Sex       = ui_coach_sex_add;
                        coachAdd.Phone     = ui_coach_phonenum_add.Trim();
                        coachAdd.Address   = ui_coach_address_add.Trim();


                        bool coachResult = new DriveMgr.BLL.CoachBLL().Add(coachAdd);
                        if (coachResult)
                        {
                            userOperateLog.OperateInfo = "添加教练";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "添加成功,教练名称:" + coachAdd.CoachName;
                            context.Response.Write("{\"msg\":\"添加成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "添加教练";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "添加失败";
                            context.Response.Write("{\"msg\":\"添加失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "添加教练";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "edit":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("coach", "edit", userFromCookie.Id))
                    {
                        int    id = Convert.ToInt32(context.Request.Params["coachid_edit"]);
                        string ui_coach_name_edit     = context.Request.Params["ui_coach_name_edit"] ?? "";
                        string ui_coach_cardnum_edit  = context.Request.Params["ui_coach_cardnum_edit"] ?? "";
                        int    ui_coach_age_edit      = Int32.Parse(context.Request.Params["ui_coach_age_edit"] ?? "-1");
                        bool   ui_coach_sex_edit      = context.Request.Params["ui_coach_sex_edit"] == "0" ? false : true;
                        string ui_coach_phonenum_edit = context.Request.Params["ui_coach_phonenum_edit"] ?? "";
                        string ui_coach_address_edit  = context.Request.Params["ui_coach_address_edit"] ?? "";

                        DriveMgr.Model.CoachModel coachEdit = new Model.CoachModel();
                        coachEdit.ID        = id;
                        coachEdit.CoachName = ui_coach_name_edit.Trim();
                        coachEdit.CardNum   = ui_coach_cardnum_edit.Trim();
                        coachEdit.Age       = ui_coach_age_edit;
                        coachEdit.Sex       = ui_coach_sex_edit;
                        coachEdit.Phone     = ui_coach_phonenum_edit.Trim();
                        coachEdit.Address   = ui_coach_address_edit.Trim();

                        if (new DriveMgr.BLL.CoachBLL().Update(coachEdit))
                        {
                            userOperateLog.OperateInfo = "修改教练";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "修改成功,教练主键:" + coachEdit.ID;
                            context.Response.Write("{\"msg\":\"修改成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "修改教练";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "修改失败";
                            context.Response.Write("{\"msg\":\"修改失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "修改教练";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "delete":
                    if (userFromCookie != null && new DriveMgr.BLL.Authority().IfAuthority("coach", "delete", userFromCookie.Id))
                    {
                        string ids = context.Request.Params["coachid_delete"].Trim(',');
                        if (new DriveMgr.BLL.CoachBLL().DeleteList(ids))
                        {
                            userOperateLog.OperateInfo = "删除教练";
                            userOperateLog.IfSuccess   = true;
                            userOperateLog.Description = "删除成功,教练主键:" + ids;
                            context.Response.Write("{\"msg\":\"删除成功!\",\"success\":true}");
                        }
                        else
                        {
                            userOperateLog.OperateInfo = "删除教练";
                            userOperateLog.IfSuccess   = false;
                            userOperateLog.Description = "删除失败";
                            context.Response.Write("{\"msg\":\"删除失败!\",\"success\":false}");
                        }
                    }
                    else
                    {
                        userOperateLog.OperateInfo = "删除教练";
                        userOperateLog.IfSuccess   = false;
                        userOperateLog.Description = "无权限,请联系管理员";
                        context.Response.Write("{\"msg\":\"无权限,请联系管理员!\",\"success\":false}");
                    }
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                case "getAllCoach":
                    string    strAllWhere = "1=1 and CoachStatus = 1";
                    DataTable dt          = new DriveMgr.BLL.CoachBLL().GetList(strAllWhere);
                    string    strAllJson  = DriveMgr.Common.JsonHelper.ToJson(dt);

                    context.Response.Write(strAllJson);

                    userOperateLog.OperateInfo = "查询教练信息";
                    userOperateLog.IfSuccess   = true;
                    userOperateLog.Description = "查询所有教练信息:";
                    DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
                    break;

                default:
                    context.Response.Write("{\"msg\":\"参数错误!\",\"success\":false}");
                    break;
                }
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"msg\":\"" + DriveMgr.Common.JsonHelper.StringFilter(ex.Message) + "\",\"success\":false}");
                userOperateLog.OperateInfo = "教练功能异常";
                userOperateLog.IfSuccess   = false;
                userOperateLog.Description = DriveMgr.Common.JsonHelper.StringFilter(ex.Message);
                DriveMgr.BLL.UserOperateLog.InsertOperateInfo(userOperateLog);
            }
        }