//初始化 protected void Page_Init(object sender, EventArgs e) { var cookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (cookie != null) { var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); empId = CoockiesID; XHD.Model.hr_employee employeeModel = emp.GetModel(emp_id); //当前员工 if (employeeModel != null) { empname = employeeModel.name; //员工姓名 uid = employeeModel.uid; //员工Uid depid = employeeModel.d_id.ToString(); //员工所在部门 factory_Id = employeeModel.factory_Id; //员工所属工厂 roletype = employeeModel.roletype.ToString(); } } else { Response.Write("<script>window.location='../login_ssn.aspx'</script>"); } }
public XHD.Model.hr_employee GetEmpModel(HttpRequest Request) { XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); var cookie = Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; string name = ticket.Name; int emp_id = int.Parse(CoockiesID); string empname = string.Empty; string uid = string.Empty; string factory_Id = string.Empty; string d_id = string.Empty; string dname = string.Empty; XHD.Model.hr_employee empModel = emp.GetModel(Convert.ToInt32(emp_id)); return(empModel); }
void Application_Error(object sender, EventArgs e) { // 在出现未处理的错误时运行的代码 Exception objErr = Server.GetLastError().GetBaseException(); if (objErr.GetType() == typeof(HttpException)) { int i = ((HttpException)objErr).GetHttpCode(); if (i == 404) { //Response.Redirect("~/ErrorPage/FileNotFind.html"); } else if (i == 403) { //Response.Redirect("~/ErrorPage/NoAccess.html"); } } else { XHD.BLL.Sys_log_Err ssle = new XHD.BLL.Sys_log_Err(); XHD.Model.Sys_log_Err model = new XHD.Model.Sys_log_Err(); model.Err_typeid = 2; model.Err_type = "CRM系统"; model.Err_time = DateTime.Now; model.Err_url = XHD.Common.PageValidate.InputText(Request.Url.ToString(), 500); model.Err_message = XHD.Common.PageValidate.InputText(objErr.Message, int.MaxValue); model.Err_source = XHD.Common.PageValidate.InputText(objErr.Source, 500); model.Err_trace = XHD.Common.PageValidate.InputText(objErr.StackTrace, int.MaxValue); model.Err_ip = Request.UserHostAddress; var cookie = Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; //检验Cookie是否已经存在 if (null == cookie) { model.Err_emp_id = -1; model.Err_emp_name = "未登录"; } else { if (XHD.Common.PageValidate.IsNumber(CoockiesID)) { XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = dsemp.Tables[0].Rows[0]["name"].ToString(); model.Err_emp_id = emp_id; model.Err_emp_name = empname; } else { model.Err_emp_id = -1; model.Err_emp_name = "异常登录"; } } ssle.Add(model); //Server.ClearError(); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; XHD.BLL.ssn_art_menu menu = new XHD.BLL.ssn_art_menu(); XHD.Model.ssn_art_menu model = new XHD.Model.ssn_art_menu(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = string.Empty; string uid = string.Empty; string factory_Id = string.Empty; if (dsemp != null && dsemp.Tables[0].Rows.Count > 0) { empname = dsemp.Tables[0].Rows[0]["name"].ToString(); uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString(); } if (request["Action"] == "GetMenu") { int appid = XHD.Common.PageValidate.IsNumber(request["appid"]) ? int.Parse(request["appid"]) : 0; string serch = "App_id=" + appid; DataSet ds = menu.GetList(0, serch, "Menu_order"); //string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); string dt = "{Rows:[" + GetTasksString(0, ds.Tables[0]) + "]}"; context.Response.Write(dt); } //Form JSON else if (request["Action"] == "form") { DataSet ds = menu.GetList("id=" + int.Parse(request["menuid"])); string dt = XHD.Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } else if (request["Action"] == "SysTree") { int appid = int.Parse(request["appid"]); DataSet ds = menu.GetList(0, "parentid=0 and App_id=" + appid, "Menu_order"); StringBuilder str = new StringBuilder(); str.Append("[{id:0,pid:0,text:'无',Menu_icon:''},"); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["menu_id"].ToString() + ",pid:" + ds.Tables[0].Rows[i]["parentid"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["menu_name"] + "',Menu_icon:'" + ds.Tables[0].Rows[i]["Menu_icon"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } //save else if (request["Action"] == "save") { model.Art_Menu = XHD.Common.PageValidate.InputText(request["T_menu_name"], 255); model.Menu_url = XHD.Common.PageValidate.InputText(request["T_menu_url"], 255); model.Menu_icon = XHD.Common.PageValidate.InputText(request["T_menu_icon"], 255); model.Menu_order = int.Parse(request["T_menu_order"]); model.Menu_type = XHD.Common.PageValidate.InputText(request["T_menu_type_val"], 255); model.parentid = int.Parse(request["T_menu_parent_val"]); model.parentname = XHD.Common.PageValidate.InputText(request["T_menu_parent"], 255); model.App_id = int.Parse(request["appid"]); model.factory_Id = factory_Id; string id = request["menuid"]; if (!string.IsNullOrEmpty(id) && id != "null") { model.Id = int.Parse(id); //DataSet ds = menu.GetList("Menu_id=" + model.Menu_id); //DataRow dr = ds.Tables[0].Rows[0]; //if (ds.Tables[0].Rows.Count > 0) //{ // model.Menu_type = ds.Tables[0].Rows[0]["Menu_type"].ToString(); //} menu.Update(model); } else { bool mid = menu.Add(model); } } else if (request["Action"] == "del") { string id = request["menuid"]; if (!string.IsNullOrEmpty(id) && id != "null") { //校验此菜单id下以及子菜单id下是否存在文章、 if (menu.ExistsArt(int.Parse(id))) { context.Response.Write('1'); //存在文章,不允许删除 } else { menu.DeleteAndChildren(int.Parse(id)); context.Response.Write('2'); //不存在文章删除,删除 } } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = string.Empty; string uid = string.Empty; if (dsemp != null && dsemp.Tables[0].Rows.Count > 0) { empname = dsemp.Tables[0].Rows[0]["name"].ToString(); uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); } //sys toolbar if (request["Action"] == "GetSys") { XHD.BLL.ssn_button btn = new XHD.BLL.ssn_button(); DataSet dsemp1 = emp.GetList("ID=" + emp_id); bool BtnAble = false; if (dsemp1.Tables[0].Rows.Count > 0) { if (dsemp1.Tables[0].Rows[0]["uid"].ToString() == "admin") { BtnAble = true; } } DataSet ds = btn.GetList(0, "Menu_id = " + int.Parse(request["mid"]), "Btn_order"); DataSSN.SSN_GetAuthorityByUid getauth = new DataSSN.SSN_GetAuthorityByUid(); string toolbarscript = "{Items:["; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { toolbarscript += "{"; toolbarscript += "type: 'button',"; toolbarscript += "text: '" + ds.Tables[0].Rows[i]["Btn_name"].ToString() + "',"; toolbarscript += "icon: '" + ds.Tables[0].Rows[i]["Btn_icon"].ToString() + "',"; if (BtnAble) { toolbarscript += "disable: true,"; } else { toolbarscript += "disable: " + getauth.GetBtnAuthority(emp_id.ToString(), ds.Tables[0].Rows[i]["Btn_id"].ToString()) + ","; } toolbarscript += "click: function() {"; toolbarscript += ds.Tables[0].Rows[i]["Btn_handler"].ToString().Replace("()", "(" + int.Parse(request["mid"]) + ")"); toolbarscript += "}"; toolbarscript += "},"; } toolbarscript = toolbarscript.Substring(0, toolbarscript.Length - 1); toolbarscript += "]}"; context.Response.Write(toolbarscript); } else { context.Response.Write("none"); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; XHD.BLL.ssn_role role = new XHD.BLL.ssn_role(); XHD.BLL.ssn_art_menu menu = new XHD.BLL.ssn_art_menu(); XHD.Model.ssn_role model = new XHD.Model.ssn_role(); XHD.BLL.ssn_visit visit = new XHD.BLL.ssn_visit(); XHD.BLL.ssn_art art = new XHD.BLL.ssn_art(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = string.Empty; string uid = string.Empty; string factory_Id = string.Empty; if (dsemp != null && dsemp.Tables[0].Rows.Count > 0) { empname = dsemp.Tables[0].Rows[0]["name"].ToString(); uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString(); } //角色保存 if (request["Action"] == "SysSave") { model.RoleName = PageValidate.InputText(request["T_role"], 250); model.RoleSort = int.Parse(request["T_RoleOrder"]); model.RoleDscript = PageValidate.InputText(request["T_Descript"], 255); model.Factory_Id = factory_Id; string id = PageValidate.InputText(request["id"], 50); if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = role.GetList("RoleID=" + int.Parse(id)); DataRow dr = ds.Tables[0].Rows[0]; model.RoleID = int.Parse(id); model.UpdateDate = DateTime.Now; model.UpdateID = emp_id; role.Update(model); } else { model.CreateID = emp_id; model.CreateDate = DateTime.Now; int rid = role.Add(model); } } //验证是否唯一 else if (request["Action"] == "Exist") { DataSet ds1 = role.GetList(" RoleName='" + XHD.Common.PageValidate.InputText(request["T_role"], 250) + "'" + " and factory_Id='" + factory_Id + "'"); context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true"); } //获取角色表格json else if (request["Action"] == "grid") { DataSet ds = role.GetList(0, "factory_Id='" + factory_Id + "'", " RoleSort"); string dt = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } //获取角色信息 else if (request["Action"] == "form") { DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"])); string dt = XHD.Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } //删除角色 else if (request["Action"] == "del") { string rid = request["id"]; bool isdel = role.Delete(int.Parse(rid)); if (isdel) { context.Response.Write("true"); } else { context.Response.Write("false"); } //角色下员工删除 XHD.BLL.ssn_role_emp rm = new XHD.BLL.ssn_role_emp(); rm.Delete("RoleID=" + int.Parse(rid)); //角色下数据权限删除 XHD.BLL.ssn_visit data_auth = new XHD.BLL.ssn_visit(); data_auth.DeleteByRole(int.Parse(rid)); //角色下功能权限删除 XHD.BLL.ssn_authority auth = new XHD.BLL.ssn_authority(); auth.DeleteWhere("Role_id=" + int.Parse(rid)); } #region 权限设置 //auth else if (request["Action"] == "treegrid") { string appidstr = request["appid"]; int appid = int.Parse(appidstr); //获取单位 string ftyid = PageValidate.InputText(request["factory_id"], 60); //设置查询条件 string wheretext = "App_id=" + appid; //限制menu string wheretext2 = ""; //限制button DataTable dt = menu.GetList(wheretext).Tables[0]; dt.Columns.Add(new DataColumn("Sysroler", typeof(string))); XHD.BLL.ssn_button btn = new XHD.BLL.ssn_button(); for (int i = 0; i < dt.Rows.Count; i++) { DataSet ds = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString() + wheretext2, "Btn_order"); string roler = ""; if (ds.Tables[0].Rows.Count > 0) { for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { roler += ds.Tables[0].Rows[j]["Btn_id"].ToString() + "|" + ds.Tables[0].Rows[j]["Btn_name"].ToString(); roler += ","; } } dt.Rows[i][dt.Columns.Count - 1] = roler; } string dt1 = "{Rows:[" + GetTasksString(0, dt) + "]}"; context.Response.Write(dt1); context.Response.End(); } //get auth else if (request["Action"] == "getauth") { string postdata = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]); JavaScriptSerializer json = new JavaScriptSerializer(); save sa = json.Deserialize <save>(postdata); XHD.Model.ssn_authority modelauth = new XHD.Model.ssn_authority(); modelauth.Role_id = int.Parse(sa.role_id); modelauth.App_ids = sa.app; modelauth.Menu_ids = sa.menu; modelauth.Button_ids = sa.btn; XHD.BLL.ssn_authority sysau = new XHD.BLL.ssn_authority(); string roledata = "0|0"; DataSet ds = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'"); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; roledata = dr["Menu_ids"] + "|" + dr["Button_ids"]; } context.Response.Write(roledata); } // save auth else if (request["Action"] == "saveauth") { string postdata = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]); JavaScriptSerializer json = new JavaScriptSerializer(); save sa = json.Deserialize <save>(postdata); XHD.Model.ssn_authority modelauth = new XHD.Model.ssn_authority(); modelauth.Role_id = int.Parse(sa.role_id); modelauth.App_ids = PageValidate.InputText(sa.app, 50); modelauth.Menu_ids = PageValidate.InputText(sa.menu, int.MaxValue); modelauth.Button_ids = PageValidate.InputText(sa.btn, int.MaxValue); modelauth.Factory_Id = factory_Id; XHD.BLL.ssn_authority sysau = new XHD.BLL.ssn_authority(); //List<string> relstbtn = new List<string>(); if (!string.IsNullOrEmpty(postdata)) { //给角色分配权限 sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'"); if (modelauth.Menu_ids != "" || modelauth.Button_ids != ",,") { sysau.Add(modelauth); } context.Response.Write("{sucess:sucess}"); } } #endregion #region 查看权限设置 //菜单显示 else if (request["Action"] == "menuList") { string appid = request["appid"]; string authtxt = PageValidate.InputText(request["auth"], 50); if (!string.IsNullOrEmpty(appid)) { string serchtxt = " App_id=" + int.Parse(appid); //-context.Response.Write(authtxt); DataSet ds = menu.GetList(0, serchtxt, " Menu_order"); StringBuilder str = new StringBuilder(); str.Append("["); str.Append(GetTreeString(0, ds.Tables[0], authtxt)); str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } } //显示菜单下的文章 else if (request["Action"] == "viewgrid") { //通过菜单id获取旗下的文章 string menuid = request["menuid"]; if (!string.IsNullOrEmpty(menuid)) { string serchtxt = " Factory_Id='" + factory_Id + "' and Art_Menu_Id=" + int.Parse(menuid) + " and is_del=0 "; DataSet ds = art.GetList(serchtxt); string dt = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(dt); } } //保存查看权限 else if (request["Action"] == "saveview") { string postdata = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]); JavaScriptSerializer json = new JavaScriptSerializer(); view sa = json.Deserialize <view>(postdata); XHD.Model.ssn_visit modelview = new XHD.Model.ssn_visit(); modelview.Role_id = int.Parse(sa.role_id); modelview.App_ids = PageValidate.InputText(sa.app, 50); modelview.Menu_ids = PageValidate.InputText(sa.menu, int.MaxValue); modelview.Art_id = PageValidate.InputText(sa.art, int.MaxValue); modelview.Factory_Id = factory_Id; modelview.Create_id = emp_id; modelview.Create_date = DateTime.Now; if (!string.IsNullOrEmpty(postdata)) { //给角色分配权限 visit.DeleteWhere("Role_id=" + modelview.Role_id + " and Menu_ids='" + modelview.Menu_ids + "'"); if (modelview.Art_id != "") { visit.Add(modelview); } context.Response.Write("{sucess:sucess}"); } } //获取当前角色的权限 else if (request["Action"] == "getview") { string postdata = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]); JavaScriptSerializer json = new JavaScriptSerializer(); view sa = json.Deserialize <view>(postdata); XHD.Model.ssn_visit modelview = new XHD.Model.ssn_visit(); modelview.Role_id = int.Parse(sa.role_id); modelview.App_ids = sa.app; modelview.Menu_ids = sa.menu; modelview.Art_id = sa.art; string roledata = ""; DataSet ds = visit.GetList("Role_id=" + modelview.Role_id + " and Menu_ids='" + modelview.Menu_ids + "'"); if (ds.Tables[0].Rows.Count > 0) { DataRow dr = ds.Tables[0].Rows[0]; roledata = dr["Art_id"].ToString(); } context.Response.Write(roledata); } #endregion }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; XHD.BLL.ssn_art_menu menu = new XHD.BLL.ssn_art_menu(); XHD.BLL.sys_info info = new XHD.BLL.sys_info(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); XHD.Model.hr_employee employeeModel = emp.GetModel(emp_id); //当前员工 string empname = string.Empty; string uid = string.Empty; string depid = string.Empty; string roletype = string.Empty; string factory_Id = string.Empty; if (employeeModel != null) { empname = employeeModel.name; //员工姓名 uid = employeeModel.uid; //员工Uid depid = employeeModel.d_id.ToString(); //员工所在部门 factory_Id = employeeModel.factory_Id; //员工所属工厂 roletype = employeeModel.roletype.ToString(); } #region GetSysApp if (request["Action"] == "GetSysApp") { DataSet ds = null; int appid = int.Parse(request["appid"]); if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { ds = menu.GetList(0, "App_id=" + appid, "Menu_order"); } else { DataSSN.SSN_GetAuthorityByUid getauth = new DataSSN.SSN_GetAuthorityByUid(); string menus = getauth.GetAuthority(emp_id.ToString(), "Menus"); //ds = menu.GetList(0, "App_id=" + appid + " and Menu_id in " + menus + " and menu_type='aft'", "Menu_order"); ds = menu.GetList(0, "App_id=" + appid + " and Id in " + menus + " ", "Menu_order"); } } string strRe = string.Empty; //==============整理返回============================================== strRe = "[" + GetTasksString(emp_id.ToString(), empname, factory_Id, 0, ds.Tables[0]) + "]"; context.Response.Write(strRe); } #endregion #region getUserTree else if (request["Action"] == "getUserTree") { XHD.BLL.Sys_online sol = new XHD.BLL.Sys_online(); XHD.Model.Sys_online model = new XHD.Model.Sys_online(); model.UserName = PageValidate.InputText(empname, 250); model.UserID = emp_id; model.LastLogTime = DateTime.Now; DataSet ds1 = sol.GetList(" UserID=" + emp_id); //添加当前用户信息 if (ds1.Tables[0].Rows.Count > 0) { sol.Update(model, " UserID=" + emp_id); } else { sol.Add(model); } //删除超时用户 //2分钟用户失效,删除 --Robert 2015-11-24 sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)"); XHD.BLL.hr_department dep = new XHD.BLL.hr_department(); XHD.BLL.hr_post hp = new XHD.BLL.hr_post(); DataSet ds = dep.GetList(0, "factory_Id='" + factory_Id + "'", "d_order"); StringBuilder str = new StringBuilder(); str.Append("["); str.Append(GetTreeString(0, ds.Tables[0], 1, "1=1")); str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } #endregion #region GetUserInfo else if (request["Action"] == "GetUserInfo") { string dt = XHD.Common.DataToJson.DataToJSON(dsemp); context.Response.Write(dt); } #endregion #region GetOnline else if (request["Action"] == "GetOnline") { XHD.BLL.Sys_online sol = new XHD.BLL.Sys_online(); XHD.Model.Sys_online model = new XHD.Model.Sys_online(); model.UserName = empname; model.UserID = emp_id; model.LastLogTime = DateTime.Now; DataSet ds1 = sol.GetList(" UserID=" + emp_id); //添加当前用户信息 if (ds1.Tables[0].Rows.Count > 0) { sol.Update(model, " UserID=" + emp_id); } else { sol.Add(model); } //} //删除超时用户 //2分钟用户失效,删除 --Robert 2015-11-24 sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)"); context.Response.Write(XHD.Common.GetGridJSON.DataTableToJSON(sol.GetAllList().Tables[0])); } #endregion #region getinfo else if (request["Action"] == "getinfo") { DataSet ds = info.GetList(" id=2 or id=3"); context.Response.Write(XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0])); } #endregion #region changepwd else if (request["Action"] == "changepwd") { DataSet ds = emp.GetPWD(emp_id); XHD.Model.hr_employee model = new XHD.Model.hr_employee(); string oldpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_oldpwd"], "MD5"); string newpwd = FormsAuthentication.HashPasswordForStoringInConfigFile(request["T_newpwd"], "MD5"); if (ds.Tables[0].Rows[0]["pwd"].ToString() == oldpwd) { model.pwd = newpwd; model.ID = (emp_id); emp.changepwd(model); context.Response.Write("true"); } else { context.Response.Write("false"); } } #endregion #region form else if (request["Action"] == "form") { string eid = PageValidate.InputText(request["id"], 50); if (eid == "epu") { eid = emp_id.ToString(); } DataSet ds = emp.GetList("id=" + int.Parse(eid)); string dt = XHD.Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } #endregion #region PersonalUpdate保存修改信息 else if (request["Action"] == "PersonalUpdate") { XHD.Model.hr_employee model = new XHD.Model.hr_employee(); model.email = PageValidate.InputText(request["T_email"], 255); model.name = PageValidate.InputText(request["T_name"], 255); model.birthday = PageValidate.InputText(request["T_birthday"], 255); model.sex = PageValidate.InputText(request["T_sex"], 255); model.idcard = PageValidate.InputText(request["T_idcard"], 255); model.tel = PageValidate.InputText(request["T_tel"], 255); model.address = PageValidate.InputText(request["T_Adress"], 255); model.schools = PageValidate.InputText(request["T_school"], 255); model.education = PageValidate.InputText(request["T_edu"], 255); model.professional = PageValidate.InputText(request["T_professional"], 255); model.remarks = PageValidate.InputText(request["T_remarks"], 255); model.title = PageValidate.InputText(request["headurl"], 255); DataRow dr = dsemp.Tables[0].Rows[0]; model.ID = emp_id; bool isup = emp.PersonalUpdate(model); if (isup) { context.Response.Write("true"); } else { context.Response.Write("false"); } C_Sys_log log = new C_Sys_log(); int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = model.name; string EventType = "个人信息修改"; int EventID = emp_id; if (dr["email"].ToString() != request["T_email"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "邮箱", dr["email"].ToString(), request["T_email"], factory_Id); } if (dr["name"].ToString() != request["T_name"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工姓名", dr["name"].ToString(), request["T_name"], factory_Id); } if (dr["birthday"].ToString() != request["T_birthday"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工生日", dr["birthday"].ToString(), request["T_birthday"], factory_Id); } if (dr["sex"].ToString() != request["T_sex"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "员工性别", dr["sex"].ToString(), request["T_sex"], factory_Id); } if (dr["idcard"].ToString() != request["T_idcard"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "身份证", dr["idcard"].ToString(), request["T_idcard"], factory_Id); } if (dr["tel"].ToString() != request["T_tel"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "手机", dr["tel"].ToString(), request["T_tel"], factory_Id); } if (dr["address"].ToString() != request["T_Adress"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "地址", dr["address"].ToString(), request["T_Adress"], factory_Id); } if (dr["schools"].ToString() != request["T_school"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "毕业学校", dr["schools"].ToString(), request["T_school"], factory_Id); } if (dr["education"].ToString() != request["T_edu"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "学历", dr["education"].ToString(), request["T_edu"], factory_Id); } if (dr["professional"].ToString() != request["T_professional"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "专业", dr["professional"].ToString(), request["T_professional"], factory_Id); } } #endregion #region tree else if (request["Action"] == "tree") { string serchtxt = " 1=1 and factory_Id = '" + factory_Id + "'"; //string authtxt = PageValidate.InputText(request["auth"], 50); //if (!string.IsNullOrEmpty(authtxt)) //{ // Data.GetDataAuth dataauth = new Data.GetDataAuth(); // string txt = dataauth.GetDataAuthByid(authtxt, "Sys_add", emp_id.ToString(), factory_Id); // string[] arr = txt.Split(':'); // switch (arr[0]) // { // case "my": // case "dep": // string did = dsemp.Tables[0].Rows[0]["d_id"].ToString(); // if (string.IsNullOrEmpty(did)) // did = "0"; // authtxt = did; // break; // case "all": // authtxt = "0"; // break; // case "depall": // DataSet dsdep = dep.GetList("factory_Id='" + factory_Id + "'"); // string deptask = GetDepTask(int.Parse(arr[1]), dsdep.Tables[0]); // string intext = arr[1] + "," + deptask; // authtxt = intext.TrimEnd(','); // break; // } //} //context.Response.Write(authtxt); XHD.BLL.hr_department dep = new XHD.BLL.hr_department(); DataSet ds = dep.GetList(0, serchtxt, " d_order"); StringBuilder str = new StringBuilder(); str.Append("["); str.Append(GetTreeString(0, ds.Tables[0], "0")); str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } #endregion }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; XHD.BLL.ssn_art_menu menu = new XHD.BLL.ssn_art_menu(); XHD.BLL.ssn_visit _visit = new XHD.BLL.ssn_visit(); XHD.BLL.ssn_art _art = new XHD.BLL.ssn_art(); //判断是否登录 if (cookie == null) { DataSet ds = new DataSet(); ds = menu.GetList("1=2"); string strRe = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(strRe); return; } var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); XHD.Model.hr_employee employeeModel = emp.GetModel(emp_id); //当前员工 string empname = string.Empty; string uid = string.Empty; string depid = string.Empty; string roletype = string.Empty; string factory_Id = string.Empty; if (employeeModel != null) { empname = employeeModel.name; //员工姓名 uid = employeeModel.uid; //员工Uid depid = employeeModel.d_id.ToString(); //员工所在部门 factory_Id = employeeModel.factory_Id; //员工所属工厂 roletype = employeeModel.roletype.ToString(); } //获取一级菜单 if (request["Action"] == "GetSysMenu1") { #region DataSet ds = new DataSet(); int appid = int.Parse(request["appid"]); if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { ds = menu.GetList(0, "App_id=" + appid + " and parentid=0", "Menu_order"); } else { DataSSN.SSN_GetAuthorityByUid getauth = new DataSSN.SSN_GetAuthorityByUid(); string menus = getauth.GetAuthority(emp_id.ToString(), "Menus"); //ds = menu.GetList(0, "App_id=" + appid + " and Menu_id in " + menus + " and menu_type='aft'", "Menu_order"); ds = menu.GetList(0, "App_id=" + appid + " and Id in " + menus + " and parentid=0", "Menu_order"); } } string strRe = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(strRe); #endregion } //获取二级级菜单 if (request["Action"] == "GetSysMenu2") { #region DataSet ds = new DataSet(); int appid = int.Parse(request["appid"]); int pid = int.Parse(request["pid"]); if (dsemp.Tables[0].Rows.Count > 0) { if (dsemp.Tables[0].Rows[0]["uid"].ToString() == "admin") { ds = menu.GetList(0, "App_id=" + appid + " and parentid=" + pid, "Menu_order"); } else { DataSSN.SSN_GetAuthorityByUid getauth = new DataSSN.SSN_GetAuthorityByUid(); string menus = getauth.GetAuthority(emp_id.ToString(), "Menus"); //ds = menu.GetList(0, "App_id=" + appid + " and Menu_id in " + menus + " and menu_type='aft'", "Menu_order"); ds = menu.GetList(0, "App_id=" + appid + " and Id in " + menus + " and parentid=" + pid, "Menu_order"); } } string strRe = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(strRe); #endregion } //获取某个菜单下的值 else if (request["Action"] == "grid") { DataSet dk = new DataSet(); string title = request["title"]; string strWhere = string.Empty; bool num = true; string atr_id = ""; if (!string.IsNullOrEmpty(request["menuid"])) { string menuId = request["menuid"]; if (menuId == "-1") { strWhere = "factory_Id='" + factory_Id + "' and is_del=0"; dk = _visit.GetListAtrId("r.empID='" + emp_id + "' "); } else { strWhere = "factory_Id='" + factory_Id + "' and Art_Menu_Id='" + menuId + "' and is_del=0"; dk = _visit.GetListAtrId("r.empID='" + emp_id + "'and v.Menu_ids='" + menuId + "' "); } if (uid != "admin") { foreach (DataRow row in dk.Tables[0].Rows) { //获取能访问的文章的id atr_id += PageValidate.InputText(row["Art_id"].ToString(), int.MaxValue).Replace("a", ""); //string Menu_ids = row["Menu_ids"].ToString(); //if (!string.IsNullOrEmpty(Menu_ids)) //{ // string[] listMenu = Menu_ids.Split(','); // foreach (var item in listMenu) // { // if (menuId == item) // { // num = true; // break; // } // } //} } //准备查询条件 if (num == true) { if (atr_id != "") { atr_id = atr_id.Substring(0, atr_id.Length - 1); strWhere += " and Id in(" + atr_id + ")"; } else { strWhere += " and 1=2"; } } else { strWhere += " and Id='-1'"; } } if (!string.IsNullOrEmpty(title)) { List <string> strList = new List <string>(); char[] charList = title.ToArray(); for (int i = 0; i < charList.Length; i++) { if (i == 0) { strWhere += " and Art_title like '%" + charList[i] + "%'"; } else { strWhere += " or Art_title like '%" + charList[i] + "%'"; } if (!strList.Contains(charList[i].ToString())) { strList.Add(charList[i].ToString()); } } Segment seg = new Segment(); seg.InitWordDics(); seg.EnablePrefix = true; seg.Separator = " "; string Seg_Title = seg.SegmentText(title, false).Trim(); string[] titleArray = Seg_Title.Split(' '); for (int i = 0; i < titleArray.Length; i++) { strWhere += " or Art_title like '%" + titleArray[i] + "%'"; //if (!strList.Contains(titleArray[i])) //{ // strList.Add(titleArray[i]); //} } //strWhere += " and Art_title like '%" + title + "%'"; DataSet ds = _art.GetList(strWhere); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string temStr = ds.Tables[0].Rows[i]["Art_Title"].ToString(); for (int j = 0; j < strList.Count; j++) { if (temStr.Contains(strList[j])) { ds.Tables[0].Rows[i]["Art_Title"] = ds.Tables[0].Rows[i]["Art_Title"].ToString().Replace(strList[j], "<span style='color:red' >" + strList[j] + "</span>"); } } } string strRe = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(strRe); } else { DataSet ds = _art.GetList(strWhere); string strRe = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); context.Response.Write(strRe); } } } //获取文章内容 if (request["Action"] == "form") { string urlList = string.Empty; if (!string.IsNullOrEmpty(request["flag"])) { DataSet ds = _art.GetList("factory_Id='" + factory_Id + "' and Id=" + int.Parse(request["flag"])); string dt = XHD.Common.DataToJson.DataToJSON(ds); context.Response.Write(dt); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = string.Empty; string uid = string.Empty; string factory_Id = string.Empty; if (dsemp != null && dsemp.Tables[0].Rows.Count > 0) { empname = dsemp.Tables[0].Rows[0]["name"].ToString(); uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString(); } if (request["Action"] == "GetSysApp") { XHD.BLL.ssn_art_app app = new XHD.BLL.ssn_art_app(); DataSSN.SSN_GetAuthorityByUid getappauth = new DataSSN.SSN_GetAuthorityByUid(); string apps = getappauth.GetAuthority(emp_id.ToString(), "Apps"); DataSet dsemp1 = emp.GetList("ID=" + emp_id); bool BtnAble = false; if (dsemp1.Tables[0].Rows.Count > 0) { if (dsemp1.Tables[0].Rows[0]["uid"].ToString() == "admin") { BtnAble = true; } } DataSet ds = app.GetList(0, "", "App_order"); string toolbarscript = "{Items:["; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { toolbarscript += "{"; toolbarscript += "type: 'button',"; toolbarscript += "text: '" + ds.Tables[0].Rows[i]["App_name"].ToString() + "',"; toolbarscript += "icon: '" + ds.Tables[0].Rows[i]["App_icon"].ToString() + "',"; if (BtnAble) { toolbarscript += "disable: true,"; } else { toolbarscript += "disable: " + getappauth.GetAppAuthority(emp_id.ToString(), ds.Tables[0].Rows[i]["id"].ToString()) + ","; } toolbarscript += "click: function () {"; toolbarscript += "f_according(" + ds.Tables[0].Rows[i]["id"].ToString() + ")"; toolbarscript += "}"; toolbarscript += "},"; } toolbarscript = toolbarscript.Substring(0, toolbarscript.Length - 1); toolbarscript += "]}"; context.Response.Write(toolbarscript); } else if (request["Action"] == "GetAppList") { XHD.BLL.ssn_art_app app = new XHD.BLL.ssn_art_app(); DataSet ds = app.GetList(0, " ", "App_order"); StringBuilder str = new StringBuilder(); str.Append("["); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { str.Append("{id:" + ds.Tables[0].Rows[i]["id"].ToString() + ",text:'" + ds.Tables[0].Rows[i]["App_name"] + "',App_icon:'../../" + ds.Tables[0].Rows[i]["App_icon"] + "'},"); } str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; XHD.BLL.ssn_role_emp rm = new XHD.BLL.ssn_role_emp(); XHD.Model.ssn_role_emp model = new XHD.Model.ssn_role_emp(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = string.Empty; string uid = string.Empty; string factory_Id = string.Empty; if (dsemp != null && dsemp.Tables[0].Rows.Count > 0) { empname = dsemp.Tables[0].Rows[0]["name"].ToString(); uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString(); } if (request["Action"] == "add") { string rid = PageValidate.InputText(request["role_id"], 50); string empids = XHD.Common.PageValidate.InputText(request["empids"], int.MaxValue); //rm.Delete(string.Format("RoleID={0} and empID in ({1})", int.Parse(rid), empids)); string[] emplist = empids.Split(','); model.RoleID = int.Parse(rid); for (int i = 0; i < emplist.Length; i++) { model.empID = int.Parse(emplist[i].ToString()); rm.Add(model); } XHD.BLL.Sys_log log = new XHD.BLL.Sys_log(); XHD.Model.Sys_log modellog = new XHD.Model.Sys_log(); modellog.EventDate = DateTime.Now; modellog.UserID = emp_id; modellog.UserName = PageValidate.InputText(empname, 255); modellog.IPStreet = context.Request.UserHostAddress; modellog.EventType = "权限人员调整"; modellog.EventID = rid.ToString(); log.Add(modellog); } else if (request["Action"] == "remove") { string rid = PageValidate.InputText(request["role_id"], 50); string empids = XHD.Common.PageValidate.InputText(request["empids"], int.MaxValue); rm.Delete(string.Format("RoleID={0} and empID in ({1})", int.Parse(rid), empids)); XHD.BLL.Sys_log log = new XHD.BLL.Sys_log(); XHD.Model.Sys_log modellog = new XHD.Model.Sys_log(); modellog.EventDate = DateTime.Now; modellog.UserID = emp_id; modellog.UserName = PageValidate.InputText(empname, 255); modellog.IPStreet = context.Request.UserHostAddress; modellog.EventType = "权限人员调整"; modellog.EventID = rid.ToString(); log.Add(modellog); } else if (request["Action"] == "emplist") { string rid = PageValidate.InputText(request["role_id"], 50); string sql = (string.Format("ID not in (select empID from ssn_role_emp where RoleID={0}) and uid !='admin' ", rid)); sql += " and factory_Id='" + factory_Id + "'"; if (!string.IsNullOrEmpty(request["stext"])) { sql += " and name like '%" + PageValidate.InputText(request["stext"], 255) + "%'"; } int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) { sortname = " ID"; } if (string.IsNullOrEmpty(sortorder)) { sortorder = " desc"; } string sorttext = " " + sortname + " " + sortorder; string Total; dsemp = emp.GetList(PageSize, PageIndex, sql, sorttext, out Total); string dt = XHD.Common.GetGridJSON.DataTableToJSON1(dsemp.Tables[0], Total); context.Response.Write(dt); } else if (request["Action"] == "emplistDep") { string rid = PageValidate.InputText(request["role_id"], 50); string depid = PageValidate.InputText(request["depid"], 50); string sql = (string.Format("ID not in (select empID from ssn_role_emp where RoleID={0}) and uid !='admin' ", rid)); sql += " and factory_Id='" + factory_Id + "' and d_id in ( " + depid + ")"; int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) { sortname = " ID"; } if (string.IsNullOrEmpty(sortorder)) { sortorder = " desc"; } string sorttext = " " + sortname + " " + sortorder; string Total; dsemp = emp.GetList(PageSize, PageIndex, sql, sorttext, out Total); string dt = XHD.Common.GetGridJSON.DataTableToJSON1(dsemp.Tables[0], Total); context.Response.Write(dt); } else if (request["Action"] == "get") { string rid = PageValidate.InputText(request["role_id"], 50); if (!string.IsNullOrEmpty(rid)) { string sql = (string.Format("ID in (select empID from ssn_role_emp where RoleID={0})", int.Parse(rid))); sql += " and factory_Id=" + factory_Id; if (!string.IsNullOrEmpty(request["stext"])) { sql += " and name like '%" + PageValidate.InputText(request["stext"], 255) + "%'"; } int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string sortname = request["sortname"]; string sortorder = request["sortorder"]; if (string.IsNullOrEmpty(sortname)) { sortname = " ID"; } if (string.IsNullOrEmpty(sortorder)) { sortorder = " desc"; } string sorttext = " " + sortname + " " + sortorder; string Total; dsemp = emp.GetList(PageSize, PageIndex, sql, sorttext, out Total); string dt = XHD.Common.GetGridJSON.DataTableToJSON1(dsemp.Tables[0], Total); context.Response.Write(dt); } else { context.Response.Write("test" + rid); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; HttpRequest request = context.Request; XHD.BLL.ssn_art _art = new XHD.BLL.ssn_art(); XHD.BLL.ssn_authority _authority = new XHD.BLL.ssn_authority(); XHD.BLL.ssn_art_menu _menu = new XHD.BLL.ssn_art_menu(); XHD.BLL.ssn_role _role = new XHD.BLL.ssn_role(); XHD.BLL.ssn_visit _visit = new XHD.BLL.ssn_visit(); C_Sys_log log = new C_Sys_log(); XHD.Model.ssn_art model = new XHD.Model.ssn_art(); var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); DataSet dsemp = emp.GetList("id=" + emp_id); string empname = string.Empty; string uid = string.Empty; string factory_Id = string.Empty; if (dsemp != null && dsemp.Tables[0].Rows.Count > 0) { empname = dsemp.Tables[0].Rows[0]["name"].ToString(); uid = dsemp.Tables[0].Rows[0]["uid"].ToString(); factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString(); } #region 加载数据grid if (request["Action"] == "grid") { int PageIndex = int.Parse(request["page"] == null ? "1" : request["page"]); int PageSize = int.Parse(request["pagesize"] == null ? "30" : request["pagesize"]); string Total = string.Empty; string filedOrder = " Art_order desc,Id desc "; string strWhere = " "; strWhere += " factory_id ='" + factory_Id + "' and is_del=0 "; if (!string.IsNullOrEmpty(request["Art_Menu_Id"])) { strWhere += " and Art_Menu_Id = '" + request["Art_Menu_Id"] + "'"; } DataSet ds = _art.GetList(PageSize, PageIndex, strWhere, filedOrder, out Total); string dt = XHD.Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], Total); context.Response.Write(dt); } #endregion #region 加载员工的所能操作的页面 tree else if (request["Action"] == "tree") { DataSet dk = null; if (uid != "admin") { string serchtxt = " a.factory_Id = '" + factory_Id + "' and a.App_ids='1' "; serchtxt += "and r.empID='" + emp_id + "'"; DataSet ds = _authority.GetListAuth(serchtxt); if (ds != null && ds.Tables[0].Rows.Count > 0) { string menu_ids = ""; foreach (DataRow item in ds.Tables[0].Rows) { menu_ids += item["Menu_ids"].ToString(); } menu_ids = PageValidate.InputText(menu_ids, int.MaxValue).Replace("m", ""); menu_ids = menu_ids.Substring(0, menu_ids.Length - 1); dk = _menu.GetList(0, " factory_Id='" + factory_Id + "' and Id in (" + menu_ids + ")", "Menu_order"); } } else { dk = _menu.GetList(0, " factory_Id='" + factory_Id + "' and app_id=1", "Menu_order"); } StringBuilder str = new StringBuilder(); str.Append("["); str.Append(GetTreeString(0, dk.Tables[0])); str.Replace(",", "", str.Length - 1, 1); str.Append("]"); context.Response.Write(str); } #endregion #region 保存save else if (request["Action"] == "save") { model.Art_title = XHD.Common.PageValidate.InputText(request["T_title"], 250); model.Art_Content = PageValidate.InputText(request["T_content"], int.MaxValue); model.Art_Content = HttpUtility.HtmlDecode(model.Art_Content); model.Art_title_en = GetSpellCode(model.Art_title);; model.image_lst = PageValidate.InputText(request["images"], int.MaxValue); model.Art_order = int.Parse(request["T_Order"]); model.factory_Id = factory_Id; model.Art_Menu_Id = Convert.ToInt32(PageValidate.InputText(request["art_Menu_Id"], 50)); string id = PageValidate.InputText(request["nid"], 50); if (!string.IsNullOrEmpty(id) && id != "null") { DataSet ds = _art.GetList("Id=" + int.Parse(id)); DataRow dr = ds.Tables[0].Rows[0]; model.Id = int.Parse(id); if (_art.Update(model)) { #region 修改访问权限 //查询该文章原来属于哪些角色下 DataSet dm = _visit.GetList(" Factory_Id='" + factory_Id + "' and find_in_set('a" + model.Id + "', Art_id)"); if (dm != null && dm.Tables[0].Rows.Count > 0) { //此次修改的文章以前已分配过角色 string oldRoleId = string.Empty; //原来所属的角色 string newRoleId = string.Empty; for (int i = 0; i < dm.Tables[0].Rows.Count; i++) { if (i == dm.Tables[0].Rows.Count - 1) { oldRoleId += dm.Tables[0].Rows[i]["Role_id"].ToString(); } else { oldRoleId += dm.Tables[0].Rows[i]["Role_id"].ToString() + ','; } } string artId = "a" + model.Id + ","; if (!string.IsNullOrEmpty(request["role_Id"].ToString())) { newRoleId = request["role_Id"].ToString(); newRoleId = newRoleId.Substring(0, newRoleId.Length - 1); _visit.UpdateN(oldRoleId, newRoleId, artId, factory_Id, model.Art_Menu_Id.Value, emp_id); } else { _visit.UpdateN(oldRoleId, "", artId, factory_Id, model.Art_Menu_Id.Value, emp_id); } log.Add_log(emp_id, empname, request.UserHostAddress, "访问权限修改", "访问权限修改", model.Id, "访问权限修改", oldRoleId, newRoleId, factory_Id); } else { //若所修改的文章原来没有分配角色,若传进来的role_Id不为空,则进行添加 if (!string.IsNullOrEmpty(request["role_Id"].ToString())) { string roleId = request["role_Id"].ToString(); roleId = roleId.Substring(0, roleId.Length - 1); string[] listRole = roleId.Split(','); foreach (var item in listRole) { DataSet df = _visit.GetList("Role_id='" + item + "'and Menu_ids='" + model.Art_Menu_Id + "' and Factory_Id='" + factory_Id + "'"); if (df != null && df.Tables[0].Rows.Count > 0) { //修改 int rId = Convert.ToInt32(df.Tables[0].Rows[0]["id"].ToString()); string art_id = df.Tables[0].Rows[0]["Art_id"].ToString(); art_id += "a" + model.Id + ","; _visit.Updates(rId, art_id); } else { //保存 XHD.Model.ssn_visit modelVisit = new XHD.Model.ssn_visit(); modelVisit.Factory_Id = factory_Id; modelVisit.Role_id = Convert.ToInt32(item); modelVisit.App_ids = "1"; modelVisit.Menu_ids = model.Art_Menu_Id.ToString(); modelVisit.Art_id = "a" + model.Id + ","; modelVisit.Create_id = emp_id; modelVisit.Create_date = DateTime.Now; _visit.Add(modelVisit); } } } } #endregion #region 日志 int UserID = emp_id; string UserName = empname; string IPStreet = request.UserHostAddress; string EventTitle = "ssn资料修改"; string EventType = "ssn资料修改"; int EventID = model.Id; if (dr["Art_title"].ToString() != request["T_title"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "资料名", dr["Art_title"].ToString(), request["T_title"].ToString(), factory_Id); } if (dr["Art_Content"].ToString() != request["T_content"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "内容", dr["Art_Content"].ToString(), model.Art_Content, factory_Id); } if (dr["image_lst"].ToString() != request["images"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "图片", dr["image_lst"].ToString(), request["images"].ToString(), factory_Id); } if (dr["Art_Menu_Id"].ToString() != request["art_Menu_Id"]) { log.Add_log(UserID, UserName, IPStreet, EventTitle, EventType, EventID, "页面Id", dr["Art_Menu_Id"].ToString(), request["art_Menu_Id"].ToString(), factory_Id); } #endregion context.Response.Write("2"); //修改成功 } else { context.Response.Write("3"); //修改失败 } } else { model.is_del = 0; model.Creater_Uid = uid; model.Creater_Name = empname; model.Create_Date = DateTime.Now; model.Creater_Id = emp_id; int artId = _art.Add(model); if (artId > 0) { #region 保存访问权限 if (!string.IsNullOrEmpty(request["role_Id"].ToString())) { string roleId = request["role_Id"].ToString(); roleId = roleId.Substring(0, roleId.Length - 1); string[] listRole = roleId.Split(','); foreach (var item in listRole) { //查询该角色是否已有分配的文章记录 DataSet df = _visit.GetList("Role_id='" + item + "'and Menu_ids='" + model.Art_Menu_Id + "' and Factory_Id='" + factory_Id + "'"); if (df != null && df.Tables[0].Rows.Count > 0) { //若已经记录,则修改 int rId = Convert.ToInt32(df.Tables[0].Rows[0]["id"].ToString()); string art_id = df.Tables[0].Rows[0]["Art_id"].ToString(); art_id += "a" + artId + ","; if (_visit.Updates(rId, art_id)) { context.Response.Write("1"); //保存成功 } else { _art.Delete(artId); context.Response.Write("0"); //保存失败 } } else { //若没有记录,则保存 XHD.Model.ssn_visit modelVisit = new XHD.Model.ssn_visit(); modelVisit.Factory_Id = factory_Id; modelVisit.Role_id = Convert.ToInt32(item); modelVisit.App_ids = "1"; modelVisit.Menu_ids = model.Art_Menu_Id.ToString(); modelVisit.Art_id = "a" + artId + ","; modelVisit.Create_id = emp_id; modelVisit.Create_date = DateTime.Now; if (_visit.Add(modelVisit)) { context.Response.Write("1"); //保存成功 } else { _art.Delete(artId); context.Response.Write("0"); //保存失败 } } } } else { context.Response.Write("1"); //保存成功 } #endregion } else { context.Response.Write("0"); //保存失败 } } } #endregion #region form else if (request["Action"] == "form") { string artId = PageValidate.InputText(request["nid"], 50); string dt; if (PageValidate.IsNumber(artId)) { DataSet ds = _art.GetList("Id=" + artId); dt = XHD.Common.DataToJson.DataToJSON(ds); } else { dt = "{}"; } context.Response.Write(dt); } #endregion #region 除del else if (request["Action"] == "del") { string artId = PageValidate.InputText(request["id"], 50); bool num = _art.Delete(Convert.ToInt32(artId)); if (num) { context.Response.Write("true"); } } #endregion #region 文章修改时获得查看权限 getRoleLiit else if (request["Action"] == "getRoleLiit") { string dt = string.Empty; string artId = PageValidate.InputText(request["nid"], 50); artId = "a" + artId; DataSet ds = _visit.GetList(" Factory_Id='" + factory_Id + "' and find_in_set('" + artId + "', Art_id)"); if (ds != null && ds.Tables[0].Rows.Count > 0) { dt = XHD.Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], "Total"); } else { dt = "{'Rows':[{'id':-9999}],'Total':'Total'}"; } context.Response.Write(dt); } #endregion #region GetRole 获得所有角色 else if (request["Action"] == "GetRole") { string dt = string.Empty; DataSet ds = _role.GetList(" Factory_Id='" + factory_Id + "'"); if (ds != null && ds.Tables[0].Rows.Count > 0) { dt = XHD.Common.GetGridJSON.DataTableToJSON1(ds.Tables[0], "Total"); } else { dt = "{'Rows':[{'id':-9999}],'Total':'Total'}"; } context.Response.Write(dt); } #endregion #region 产文章图片 else if (request["Action"] == "album") { string photo = request["photo"]; //文件路径goods_gallery 商品相册表 string nowfileName1 = string.Empty; if (!string.IsNullOrEmpty(photo)) { photo = photo.Substring(photo.LastIndexOf('\\') + 1); string sExt1 = photo.Substring(photo.LastIndexOf(".")).ToLower(); DateTime now1 = DateTime.Now; nowfileName1 = XHD.Common.TimeParser.GenerateTimeStamp(DateTime.Now) + sExt1; } if (request.Files.Count > 0 && (!string.IsNullOrEmpty(photo))) { HttpPostedFile uploadFile = request.Files[0]; ////生成缩略图 //SmallImg(uploadFile.InputStream, uploadFile.FileName, context, nowfileName1); ////生成主图 //MainImg(uploadFile.InputStream, uploadFile.FileName, context, nowfileName1); uploadFile.SaveAs(context.Server.MapPath(@"~/file/ssn_artImg/" + nowfileName1)); } context.Response.Write("file/ssn_artImg/" + nowfileName1); } #endregion #region 移除图片 else if (request["Action"] == "remove") { string src = request["srcvalue"]; string file = System.Web.HttpContext.Current.Server.MapPath("../" + src); if (System.IO.File.Exists(file)) { File.Delete(file); } } #endregion #region 判断标题是否重复 else if (request["Action"] == "validate") { string title = request["T_title"]; string id = request["T_cid"]; string artMenu_Id = request["art_Menu_Id"]; if (string.IsNullOrEmpty(id) || id == "null") { id = "0"; } DataSet ds = _art.GetList("Art_title = '" + PageValidate.InputText(title, 255) + "' and Art_Menu_Id='" + artMenu_Id + "' and factory_Id='" + factory_Id + "' and Id!=" + int.Parse(id) + " and is_del=0"); if (ds.Tables[0].Rows.Count > 0) { context.Response.Write("false"); } else { context.Response.Write("true"); } } #endregion //#region 获取文章图片 //else if (request["Action"] == "formGallery") //{ // string goods_id = request["goods_id"]; // if (!string.IsNullOrEmpty(goods_id)) // { // DataSet ds = null; // if (request["type"] == "1") // ds = gallery.GetList(" goods_id='" + goods_id + "'"); // else if (request["type"] == "2") // ds = gallery.GetListCopy(" goods_id='" + goods_id + "'"); // string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]); // context.Response.Write(dt); // } //} //#endregion }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.Charset = "utf-8"; HttpRequest request = context.Request; if (request["Action"] == "login") { XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); XHD.BLL.Sys_FactoryInfo fty = new XHD.BLL.Sys_FactoryInfo(); string username = PageValidate.InputText(request["username"], 255); //string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5"); string password = PageValidate.InputText(request["password"], 255); string validate = PageValidate.InputText(request["validate"], 255); //SQL注入式攻击过滤=========================================================================================== string path = context.Server.MapPath(@"../file/SQLFile.txt"); if (CommonData.getSQLPercolation(username.ToUpper(), path)) { context.Response.Write("999");//系统错误 return; } //============================================================================================================ if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password)) { //if (validate == context.Session["CheckCode"].ToString() || validate.ToLower() == context.Session["CheckCode"].ToString().ToLower()) //{ //DataSet ds = emp.GetList(" uid='" + username + "' and pwd='" + password + "'"); XHD.Model.hr_employee empModel = emp.LoginUser(username); //IP 限制==================================================================================================== string vrip = GetClientIPv4Address(); List <string> lstIp = new List <string>(); lstIp.Add("219.146.197.91"); //电信IP地址 lstIp.Add("60.213.50.226"); //联通IP地址 lstIp.Add("172.178.1.118"); //本地(邢荣) lstIp.Add("172.178.1.211"); //本地(陈伟) lstIp.Add("172.178.1.100"); //本地(陈伟) lstIp.Add("172.178.1.203"); //本地(robert) lstIp.Add("172.178.1.201"); //本地(李明) lstIp.Add("172.178.1.79"); //本地(王德胜) lstIp.Add("172.178.1.117"); //本地(王立全) lstIp.Add("172.178.1.243"); //本地(王虎) lstIp.Add("172.178.1.56"); //本地(马萧) lstIp.Add("172.178.1.29"); //本地(张杰) lstIp.Add("172.178.1.45"); //本地(张顾严) lstIp.Add("172.178.1.133"); //本地(吴瑞曾) //if (!lstIp.Contains(vrip)) //{ // //修改:robert, 2016-06-04 过滤特殊人群,当前:王频频wpp6274======== // if (username.Trim() != "wpp6274" && username.Trim() != "gjc1010") // { // context.Response.Write("6");//ip受限制 // return; // } // //======================================================================= //} //============================================================================================================ if (empModel != null && empModel.pwd == password.ToUpper()) { //存在该 uid的用户,并且 pwd-密码正确;执行以下内容 //if (ds.Tables[0].Rows.Count > 0) //{ if (empModel.uid.Trim() == "admin") { #region //string userid = empModel.ID.ToString(); FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, empModel.uid, DateTime.Now, DateTime.Now.AddMinutes(20), true, empModel.ID.ToString(), "/" ); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); cookie.HttpOnly = true; context.Response.Cookies.Add(cookie); //FormsAuthentication.SetAuthCookie(userid, true); //日志 XHD.BLL.Sys_log log = new XHD.BLL.Sys_log(); XHD.Model.Sys_log modellog = new XHD.Model.Sys_log(); modellog.EventType = "系统登录"; modellog.EventDate = DateTime.Now; modellog.UserID = empModel.ID; modellog.UserName = empModel.name; modellog.IPStreet = request.UserHostAddress; modellog.Factory_Id = empModel.factory_Id; log.Add(modellog); //online XHD.BLL.Sys_online sol = new XHD.BLL.Sys_online(); XHD.Model.Sys_online model = new XHD.Model.Sys_online(); model.UserName = empModel.name; model.UserID = empModel.ID; model.LastLogTime = DateTime.Now; DataSet ds1 = sol.GetList(" UserID=" + empModel.ID); //添加当前用户信息 if (ds1.Tables[0].Rows.Count > 0) { sol.Update(model, " UserID=" + empModel.ID); } else { sol.Add(model); } //删除超时用户 //2分钟用户失效,删除 --Robert 2015-11-24 sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)"); //验证完毕,允许登录 context.Response.Write("2"); #endregion } else { #region DataSet dsfty = fty.GetList("Factory_Id='" + empModel.factory_Id + "'"); string isDelete = dsfty.Tables[0].Rows[0]["IsDelete"].ToString(); if (int.Parse(isDelete) == 0) { if (empModel.canlogin.ToString() == "1") { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, username, DateTime.Now, DateTime.Now.AddMinutes(20), true, empModel.ID.ToString(), "/" ); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); cookie.HttpOnly = true; context.Response.Cookies.Add(cookie); //FormsAuthentication.SetAuthCookie(userid, true); //日志 XHD.BLL.Sys_log log = new XHD.BLL.Sys_log(); XHD.Model.Sys_log modellog = new XHD.Model.Sys_log(); modellog.EventType = "系统登录"; modellog.EventDate = DateTime.Now; modellog.UserID = empModel.ID; modellog.UserName = empModel.name; modellog.IPStreet = request.UserHostAddress; modellog.Factory_Id = empModel.factory_Id; log.Add(modellog); //online XHD.BLL.Sys_online sol = new XHD.BLL.Sys_online(); XHD.Model.Sys_online model = new XHD.Model.Sys_online(); model.UserName = empModel.name; model.UserID = empModel.ID; model.LastLogTime = DateTime.Now; DataSet ds1 = sol.GetList(" UserID=" + empModel.ID); //添加当前用户信息 if (ds1.Tables[0].Rows.Count > 0) { sol.Update(model, " UserID=" + empModel.ID); } else { sol.Add(model); } //删除超时用户 //2分钟用户失效,删除 --Robert 2015-11-24 sol.Delete(" LastLogTime<date_sub(now(), interval 2 minute)"); //验证完毕,允许登录 context.Response.Write("2"); } else { context.Response.Write("4");//不允许登录 } } else { context.Response.Write("5");//不允许登录 } #endregion } } else { context.Response.Write("1");//用户名或密码错误 } //} //else //{ // context.Response.Write("0");//验证码错误 //} } else { context.Response.Write("999");//系统数据错误 } } else if (request["Action"] == "logout") { #region var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; if (null != cookie) { var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; FormsAuthentication.SignOut(); context.Response.Write("true"); //online XHD.BLL.Sys_online sol = new XHD.BLL.Sys_online(); try { if (!string.IsNullOrEmpty(CoockiesID)) { sol.Delete(" UserID=" + int.Parse(CoockiesID)); } } catch { } } #endregion } else if (request["Action"] == "checkpwd") { #region var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName]; var ticket = FormsAuthentication.Decrypt(cookie.Value); string CoockiesID = ticket.UserData; XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee(); int emp_id = int.Parse(CoockiesID); string password = FormsAuthentication.HashPasswordForStoringInConfigFile(request["password"], "MD5"); DataSet ds = emp.GetList(string.Format("ID={0} and pwd='{1}'", emp_id, password)); if (ds.Tables[0].Rows.Count > 0) { context.Response.Write("{sucess:sucess}"); } else { context.Response.Write("{sucess:false}"); } #endregion } }