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; 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]; 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); } }