public static string GetMyORGNoZsTree(string DEPT_CODE, string PARENT_CODE, int DEPT_FLAG = 0) { string strJson = string.Empty; //获得组织 List <SYS_DEPTANDMEMBER> listOrgMenu = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_FLAG == DEPT_FLAG && (m.PARENT_CODE.StartsWith(DEPT_CODE) || m.DEPT_CODE == DEPT_CODE)) .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE) .Select(org => new SYS_DEPTANDMEMBER { ORGRY_CODE = org.DEPT_CODE, PARENT_CODE = org.PARENT_CODE, ORGRY_NAME = org.DEPT_NAME, ICO = org.C_ICO, RYMOBILE = "", STATE = org.STATUS_FLAG //0关闭 }) .ToList(); if (DEPT_FLAG == 1) { listOrgMenu = GetDeptTree(listOrgMenu); } List <EasyUITreeNode> listTreeNodes = SYS_DEPTANDMEMBER.ConvertTreeNodes(listOrgMenu, PARENT_CODE, DEPT_CODE, false); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }
/// <summary> /// 获取气象监测组织机构树 /// </summary> /// <param name="DEPT_CODE"></param> /// <param name="PARENT_CODE"></param> /// <param name="isCheckAll"></param> /// <returns></returns> public static string GetWeatherDeptTree(string DEPT_CODE, string PARENT_CODE, bool isCheckAll) { string strJson = string.Empty; List <SYS_DEPTANDMEMBER_TEMP> listOrgRy = new List <SYS_DEPTANDMEMBER_TEMP>(); List <SYS_DEPT> listMenu = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_CODE.Length <= 8 && (m.PARENT_CODE.StartsWith(DEPT_CODE) || m.DEPT_CODE == DEPT_CODE)) .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE).ToList(); if (listMenu.Count > 0) { foreach (SYS_DEPT org in listMenu) { listOrgRy.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = org.DEPT_CODE, PARENT_CODE = org.PARENT_CODE, ORGRY_NAME = org.DEPT_NAME, ICO = org.C_ICO, RYMOBILE = "", STATE = org.STATUS_FLAG//0关闭 }); } } List <ZTreeNode> listTreeNodes = SYS_DEPTANDMEMBER_TEMP.ConvertZTreeNodes(listOrgRy, PARENT_CODE, DEPT_CODE, isCheckAll); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }
public ActionResult ReadXls() { AjaxMsgModel amm = new Message().NewAmm; amm.Msg = "导入文件格式不正确!"; #region 第一步EXCEL转DT int rowindex = 2; //开始行 int sheetindex = 0; //工作表索引 amm = new ExcelHelper().ToDataTable(System.Web.HttpContext.Current.Request.Files, sheetindex, rowindex, amm); if (amm.Statu == AjaxStatu.err) //如果转DT不成功 { return(ObjToJson.GetToJson(amm, true)); } DataTable dt = amm.Data as DataTable; amm.Data = null; #endregion #region 第二步DT转LIST amm = DataTableToList <SYS_MEMBER> .ConvertToList(dt, rowindex, amm); //转换为LIST集合 if (amm.Statu == AjaxStatu.err) //如果转LIST不成功 { return(ObjToJson.GetToJson(amm, true)); } List <SYS_MEMBER> list_SYS_MEMBER = amm.Data as List <SYS_MEMBER>; amm.Data = null; #endregion #region 第三步业务判断并插入数据库 //错误集合 List <TableToListErrorModel> errorList = new List <TableToListErrorModel>(); int rowline = 0; foreach (SYS_MEMBER member in list_SYS_MEMBER) { rowline++; if (member.NAME == "")//如果没有姓名 { amm.Statu = AjaxStatu.err; errorList.Add( new TableToListErrorModel() { rowIndex = rowindex + rowline, columnIndex = 0,//dt.Columns.IndexOf(tempName) + 1 errorInfo = "姓名必须输入", errorCause = "姓名必须输入" }); } } if (amm.Statu == AjaxStatu.err)//如果不存在 { amm.Data = errorList; return(ObjToJson.GetToJson(amm, true)); } //业务判断并插入数据库 return(ObjToJson.GetToJson(Model_SYS_MEMBER.AddList(list_SYS_MEMBER), true)); #endregion }
public ActionResult GetSysOrderByMenuID(string id) { var list = oc.BllSession.ISYS_MENU_HELPCONTENTService.Entities .Where(s => s.MENU_ID.Equals(id)) .Select(s => new { id = s.CONTENT_ORDER, text = s.CONTENT_ORDER }).Distinct(); return(Content(ObjToJson.GetToJson(list))); }
public ActionResult GetMyMenuListTree() { List <string> listMuenId = oc.UserMenuPermission .Where(u => string.IsNullOrEmpty(u.GIS_ORDER)).Select(u => u.MENU_ID).ToList(); List <SYS_MENU> listMenu = oc.BllSession.ISYS_MENUService.Entities .Where(m => listMuenId.Contains(m.MENU_ID) && m.MENU_LEVEL < 3 ) .OrderBy(m => m.MENU_ID).OrderBy(m => m.MENU_ORDER).ToList(); return(Content(ObjToJson.GetToJson(SYS_MENU.ConvertTreeNodes(listMenu, "0")))); }
/// <summary> /// 获取用户对应部门组织树 /// </summary> /// <returns></returns> public static string GetMyORGandRYTree(string DEPT_CODE, string PARENT_CODE, bool isCheckAll) { string strJson = string.Empty; List <SYS_DEPTANDMEMBER_TEMP> listOrgRy = new List <SYS_DEPTANDMEMBER_TEMP>(); //获取人员 List <SYS_MEMBER> listRyMenu = oc.BllSession.ISYS_MEMBERService.GetListByCondition <string>(m => m.DEL_FLAG == "0" && m.LOCATION_FLAG == "1" && m.DEPT_CODE.StartsWith(DEPT_CODE), m => m.MOBILE).Select(mb => mb.ToPOCO()).ToList(); if (listRyMenu.Count > 0) { foreach (SYS_MEMBER ry in listRyMenu) { string icon = "icon-Off-line"; if (ry.MOBILE_STATE == "1") { icon = "icon-status_busy"; } listOrgRy.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = ry.MOBILE, PARENT_CODE = ry.DEPT_CODE, ORGRY_NAME = ry.NAME, ICO = icon, RYMOBILE = ry.MOBILE, STATE = "0"//关闭 }); } } //获得组织 //List<SYS_ORG> listMenu = oc.BllSession.ISYS_ORGService.GetListByCondition<string>(m => m.DEL_FLAG == "0", m => m.DEPT_CODE).Select(mb => mb.ToPOCO()).ToList(); List <SYS_DEPT> listMenu = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && (m.PARENT_CODE.StartsWith(DEPT_CODE) || m.DEPT_CODE == DEPT_CODE)) .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE).ToList(); if (listMenu.Count > 0) { foreach (SYS_DEPT org in listMenu) { listOrgRy.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = org.DEPT_CODE, PARENT_CODE = org.PARENT_CODE, ORGRY_NAME = org.DEPT_NAME, ICO = org.C_ICO, RYMOBILE = "", STATE = org.STATUS_FLAG//0关闭 }); } } //List<EasyUITreeNode> listTreeNodes = SYS_DEPTANDMEMBER.ConvertTreeNodes(listOrgRy, PARENT_CODE, DEPT_CODE, isCheckAll); List <ZTreeNode> listTreeNodes = SYS_DEPTANDMEMBER_TEMP.ConvertZTreeNodes(listOrgRy, PARENT_CODE, DEPT_CODE, isCheckAll); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }
public ActionResult GetMyOneMenu() { string strJson = "[]"; //获取用户默认子系统menuid string defuMenuID = GetDefuMenu(); if (!string.IsNullOrEmpty(defuMenuID)) { SYS_MENU parMenu = oc.BllSession.ISYS_MENUService.Entities.Where(u => u.MENU_ID.Equals(defuMenuID)).FirstOrDefault(); string defuMenu = string.Empty; try { if (!string.IsNullOrEmpty(parMenu.DEFMENU_ID)) { defuMenu = parMenu.DEFMENU_ID.Substring(0, 4); } } catch { defuMenu = string.Empty; } List <SYS_MENU> listMenu = oc.UserMenuPermission.Where(m => m.PARENT_ID.Equals(defuMenuID) //&& !Constant.PersonLocationMenuID.Split(',').Contains(m.MENU_ID) && string.IsNullOrEmpty(m.GIS_ORDER)).OrderBy(m => m.MENU_ORDER).ToList(); //.OrderByDescending(m => m.GIS_ORDER).ThenBy(m => m.MENU_ORDER).ToList(); if (listMenu.Count > 0) { if (string.IsNullOrEmpty(defuMenu)) { defuMenu = listMenu[0].MENU_ID; } List <EasyUITreeNode> listTreeNodes = SYS_MENU.ConvertTreeNodes(listMenu, defuMenuID); foreach (EasyUITreeNode node in listTreeNodes) { if (node.id.Equals(defuMenu)) { node.isdefuopen = "Y"; } else { node.isdefuopen = "N"; } } strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); } } return(Content(strJson)); }
public static string GetCarTree_TWO(string DEPT_CODE, string PARENT_CODE, bool isCheckAll) { string strJson = string.Empty; List <SYS_DEPTANDMEMBER_TEMP> listOrgRy = new List <SYS_DEPTANDMEMBER_TEMP>(); //获取人员 List <CAR_BDATA_CAR> listCarMenu = oc.BllSession.ICAR_BDATA_CARService.GetListByCondition <string>(m => m.DEPT_CODE.StartsWith(DEPT_CODE), m => m.CAR_NO).Select(mb => mb.ToPOCO()).ToList(); if (listCarMenu.Count > 0) { foreach (CAR_BDATA_CAR ry in listCarMenu) { listOrgRy.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = ry.CAR_NO, PARENT_CODE = ry.DEPT_CODE, ORGRY_NAME = ry.CAR_LICENSENO, ICO = "car-Off-line", RYMOBILE = ry.CAR_NO, STATE = "0"//关闭 }); } } //获得组织 //List<SYS_ORG> listMenu = oc.BllSession.ISYS_ORGService.GetListByCondition<string>(m => m.DEL_FLAG == "0", m => m.DEPT_CODE).Select(mb => mb.ToPOCO()).ToList(); List <SYS_DEPT> listMenu = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && (m.PARENT_CODE.StartsWith(DEPT_CODE) || m.DEPT_CODE == DEPT_CODE)) .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE).ToList(); if (listMenu.Count > 0) { foreach (SYS_DEPT org in listMenu) { listOrgRy.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = org.DEPT_CODE, PARENT_CODE = org.PARENT_CODE, ORGRY_NAME = org.DEPT_NAME, ICO = org.C_ICO, RYMOBILE = "", STATE = org.STATUS_FLAG//0关闭 }); } } List <ZTreeNode> listTreeNodes = SYS_DEPTANDMEMBER_TEMP.ConvertZTreeNodes(listOrgRy, PARENT_CODE, DEPT_CODE, isCheckAll); //return ObjToJson.GetToJson(listTreeNodes, true); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }
/// <summary> /// 获取所有组织与人员树 /// </summary> /// <returns></returns> public static string GetORGandRYTree() { string strJson = string.Empty; List <SYS_DEPTANDMEMBER> listOrgRy = new List <SYS_DEPTANDMEMBER>(); //获取人员 List <SYS_MEMBER> listRyMenu = oc.BllSession.ISYS_MEMBERService.GetListByCondition <string>(m => m.DEL_FLAG == "0" && m.LOCATION_FLAG == "1", m => m.MOBILE).Select(mb => mb.ToPOCO()).ToList(); if (listRyMenu.Count > 0) { foreach (SYS_MEMBER ry in listRyMenu) { listOrgRy.Add(new SYS_DEPTANDMEMBER() { ORGRY_CODE = ry.MOBILE, PARENT_CODE = ry.DEPT_CODE, ORGRY_NAME = ry.NAME, ICO = "icon-Off-line", RYMOBILE = ry.MOBILE, STATE = "0"//关闭 }); } } //获得组织 List <SYS_DEPT> listMenu = oc.BllSession.ISYS_DEPTService.GetListByCondition <string>(m => m.DEL_FLAG == "0", m => m.DEPT_CODE) .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE).Select(mb => mb.ToPOCO()).ToList(); if (listMenu.Count > 0) { foreach (SYS_DEPT org in listMenu) { listOrgRy.Add(new SYS_DEPTANDMEMBER() { ORGRY_CODE = org.DEPT_CODE, PARENT_CODE = org.PARENT_CODE, ORGRY_NAME = org.DEPT_NAME, ICO = org.C_ICO, RYMOBILE = "", STATE = org.STATUS_FLAG//0关闭 }); } } List <EasyUITreeNode> listTreeNodes = SYS_DEPTANDMEMBER.ConvertTreeNodes(listOrgRy, "0", "", false); //return ObjToJson.GetToJson(listTreeNodes, true); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }
public ActionResult GetMyZeroMenu() { string strJson = "[]"; List <SYS_MENU> listMenu = oc.BllSession.ISYS_MENUService.Entities .Where(m => m.PARENT_ID.Equals(Constant.systemParID)).OrderBy(m => m.MENU_ORDER).ToList();// oc.BllSession.ISYS_MENUService.Entities.ToList();//.GetListByCondition<decimal?>(null, ma => ma.MENU_LEVEL).Select(mb => mb.ToPOCO()).ToList(); //2015-11-06 新增不显示菜单 listMenu = listMenu.Where(u => string.IsNullOrEmpty(u.ISSHOW_FLAG) || (!string.IsNullOrEmpty(u.ISSHOW_FLAG) && !u.ISSHOW_FLAG.Equals("0"))).ToList(); //List<string> showlistMenu=listMenu.Select(u=>u.MENU_ID).ToList(); if (listMenu.Count > 0) { List <EasyUITreeNode> listTreeNodes = SYS_MENU.ConvertTreeNodes(listMenu, Constant.systemParID); //获取用户拥有权限的子系统 List <string> hasPermissionSyss = oc.UserMenuPermission.Where(u => u.PARENT_ID.Equals(Constant.systemParID)).OrderBy(u => u.MENU_ORDER) .Select(u => u.MENU_ID).ToList(); //获取用户默认子系统 string defuMenuID = GetDefuMenu(); foreach (EasyUITreeNode node in listTreeNodes) { if (node.id.Equals(defuMenuID)) { node.isdefu = "Y"; } else { node.isdefu = "N"; } if (hasPermissionSyss.Contains(node.id)) { node.haspermission = "Y"; } else { node.haspermission = "N"; } } strJson = ObjToJson.GetToJson(listTreeNodes.OrderByDescending(m => m.haspermission)).Replace("Checked", "checked"); } return(Content(strJson)); }
public ActionResult ReadXls() { //本功能只支持一次全部部门和人员导入,不适合追加和修改 AjaxMsgModel amm = new Message().NewAmm; amm.Msg = "导入文件格式不正确!"; #region 第一步EXCEL转DT int rowindex = 2; //开始行 int sheetindex = 0; //工作表索引 amm = new ExcelExtHelper().ToDataTable(System.Web.HttpContext.Current.Request.Files, sheetindex, rowindex, amm); if (amm.Statu == AjaxStatu.err) //如果转DT不成功 { return(ObjToJson.GetToJson(amm, true)); } DataTable dt = amm.Data as DataTable; amm.Data = null; #endregion #region 第二步DT转LIST amm = DataTableToList <VIEW_SYS_DEPT> .ConvertToList(dt, rowindex, amm); //转换为LIST集合 if (amm.Statu == AjaxStatu.err) //如果转LIST不成功 { return(ObjToJson.GetToJson(amm, true)); } List <VIEW_SYS_DEPT> list_VIEW_SYS_DEPT = amm.Data as List <VIEW_SYS_DEPT>; amm.Data = null; #endregion #region 第三步业务判断并插入数据库 List <SYS_DEPT> list_SYS_DEPT = new List <SYS_DEPT>(); List <SYS_MEMBER> list_SYS_MEMBER = new List <SYS_MEMBER>(); Dictionary <string, string> DeptCodeMap = new Dictionary <string, string>(); Dictionary <string, string> MemberIntelligenceMap = new Dictionary <string, string>(); List <SYS_INTELLIGENCE_DIC> lisMI = oc.BllSession.ISYS_INTELLIGENCE_DICService.Entities.ToList(); foreach (SYS_INTELLIGENCE_DIC item in lisMI) { MemberIntelligenceMap.Add(item.DIC_NAME, item.DIC_ID); } //错误集合 //List<TableToListErrorModel> errorList = new List<TableToListErrorModel>(); //int rowline = 0; if (list_VIEW_SYS_DEPT.Count > 0) { try { //局 List <VIEW_SYS_DEPT> listDEPT = list_VIEW_SYS_DEPT.Where(u => u.DEPT_NAME != "" && u.DEPT_CODE != "").GroupBy(u => new { u.DEPT_NAME, u.DEPT_CODE }) .Select(g => new VIEW_SYS_DEPT { DEPT_CODE = g.Key.DEPT_CODE, DEPT_NAME = g.Key.DEPT_NAME }).ToList(); if (listDEPT.Count > 0) { foreach (VIEW_SYS_DEPT jgs in listDEPT) { if (oc.BllSession.ISYS_DEPTService.Entities.Where(u => u.DEPT_CODE == jgs.DEPT_CODE).Count() == 0) { //如果数据库无此部门编码则添加 list_SYS_DEPT.Add(new SYS_DEPT() //局 { DEPT_CODE = jgs.DEPT_CODE, DEPT_NAME = jgs.DEPT_NAME, PARENT_CODE = "0", DEPT_ORDER = 0, DEL_FLAG = "0", STATUS_FLAG = "0", C_ICO = "icon-DepartMent", DEPT_FLAG = 0 }); } DeptCodeMap.Add(jgs.DEPT_NAME, jgs.DEPT_CODE); } } //工务段 List <VIEW_SYS_DEPT> listDEPT_GWD = list_VIEW_SYS_DEPT.Where(u => u.DEPT_NAME != "" && u.DEPT_CODE != "" && u.GWD_NAME != "" && u.GWD_CODE != "") .GroupBy(u => new { u.DEPT_NAME, u.DEPT_CODE, u.GWD_NAME, u.GWD_CODE }) .Select(g => new VIEW_SYS_DEPT { DEPT_NAME = g.Key.DEPT_NAME, GWD_NAME = g.Key.GWD_NAME, GWD_CODE = g.Key.GWD_CODE }).ToList(); if (listDEPT_GWD.Count > 0) { foreach (VIEW_SYS_DEPT gwd in listDEPT_GWD) { if (oc.BllSession.ISYS_DEPTService.Entities.Where(u => u.DEPT_CODE == gwd.GWD_CODE).Count() == 0) { //如果数据库无此部门编码则添加 list_SYS_DEPT.Add(new SYS_DEPT() //段 { DEPT_CODE = gwd.GWD_CODE, DEPT_NAME = gwd.GWD_NAME, PARENT_CODE = gwd.GWD_CODE.Substring(0, 2), DEPT_ORDER = 0, DEL_FLAG = "0", STATUS_FLAG = "0", C_ICO = "icon-DepartMent", DEPT_FLAG = 0 }); } DeptCodeMap.Add(gwd.DEPT_NAME + "_" + gwd.GWD_NAME, gwd.GWD_CODE); } } //虚拟目录列 List <VIEW_SYS_DEPT> listDEPT_XN = list_VIEW_SYS_DEPT.Where(u => u.DEPT_NAME != "" && u.DEPT_CODE != "" && u.GWD_NAME != "" && u.GWD_CODE != "" && u.XN_NAME != "") .OrderBy(u => u.GWD_CODE).GroupBy(u => new { u.DEPT_NAME, u.DEPT_CODE, u.GWD_NAME, u.GWD_CODE, u.XN_NAME }) .Select(g => new VIEW_SYS_DEPT { DEPT_NAME = g.Key.DEPT_NAME, GWD_NAME = g.Key.GWD_NAME, XN_NAME = g.Key.XN_NAME, GWD_CODE = g.Key.GWD_CODE }).ToList(); if (listDEPT_XN.Count > 0) { string gwdcode = ""; int i = 1; foreach (VIEW_SYS_DEPT xn in listDEPT_XN) { if (gwdcode != xn.GWD_CODE)//如果是新父级,则重新编号 { i = 1; gwdcode = xn.GWD_CODE; } string xnNum = i < 10 ? "0" + i.ToString() : i.ToString(); string xncode = xn.GWD_CODE + xnNum; if (oc.BllSession.ISYS_DEPTService.Entities.Where(u => u.DEPT_CODE == xncode).Count() == 0) { //如果数据库无此部门编码则添加 list_SYS_DEPT.Add(new SYS_DEPT() //虚拟目录列 { DEPT_CODE = xn.GWD_CODE + xnNum, DEPT_NAME = xn.XN_NAME, PARENT_CODE = xn.GWD_CODE, DEPT_ORDER = 0, DEL_FLAG = "0", STATUS_FLAG = "0", C_ICO = "icon-DepartMent", DEPT_FLAG = 0 }); } DeptCodeMap.Add(xn.DEPT_NAME + "_" + xn.GWD_NAME + "_" + xn.XN_NAME, xn.GWD_CODE + xnNum); i++; } } //车间 List <VIEW_SYS_DEPT> listDEPT_CJ = list_VIEW_SYS_DEPT.Where(u => u.DEPT_NAME != "" && u.DEPT_CODE != "" && u.GWD_NAME != "" && u.GWD_CODE != "" && u.XN_NAME != "" && u.CJ_NAME != "") .OrderBy(u => u.XN_NAME).GroupBy(u => new { u.DEPT_NAME, u.DEPT_CODE, u.GWD_NAME, u.GWD_CODE, u.XN_NAME, u.CJ_NAME }) .Select(g => new VIEW_SYS_DEPT { DEPT_NAME = g.Key.DEPT_NAME, GWD_NAME = g.Key.GWD_NAME, XN_NAME = g.Key.XN_NAME, CJ_NAME = g.Key.CJ_NAME }).ToList(); if (listDEPT_CJ.Count > 0) { string xnname = ""; int j = 1; foreach (VIEW_SYS_DEPT cj in listDEPT_CJ) { try { if (xnname != cj.XN_NAME)//如果是新父级,则重新编号 { j = 1; xnname = cj.XN_NAME; } string cjNum = j < 10 ? "0" + j.ToString() : j.ToString(); string cjcode = DeptCodeMap[cj.DEPT_NAME + "_" + cj.GWD_NAME + "_" + cj.XN_NAME] + cjNum; if (oc.BllSession.ISYS_DEPTService.Entities.Where(u => u.DEPT_CODE == cjcode).Count() == 0) { //如果数据库无此部门编码则添加 list_SYS_DEPT.Add(new SYS_DEPT() //车间 { DEPT_CODE = DeptCodeMap[cj.DEPT_NAME + "_" + cj.GWD_NAME + "_" + cj.XN_NAME] + cjNum, DEPT_NAME = cj.CJ_NAME, PARENT_CODE = DeptCodeMap[cj.DEPT_NAME + "_" + cj.GWD_NAME + "_" + cj.XN_NAME], DEPT_ORDER = 0, DEL_FLAG = "0", STATUS_FLAG = "0", C_ICO = "icon-DepartMent", DEPT_FLAG = 0 }); } DeptCodeMap.Add(cj.DEPT_NAME + "_" + cj.GWD_NAME + "_" + cj.XN_NAME + "_" + cj.CJ_NAME, DeptCodeMap[cj.DEPT_NAME + "_" + cj.GWD_NAME + "_" + cj.XN_NAME] + cjNum); j++; } catch (Exception ex) { string a = cj.CJ_NAME; throw ex; } } } //工区 List <VIEW_SYS_DEPT> listDEPT_GQ = list_VIEW_SYS_DEPT.Where(u => u.DEPT_NAME != "" && u.DEPT_CODE != "" && u.GWD_NAME != "" && u.GWD_CODE != "" && u.XN_NAME != "" && u.GQ_NAME != "" && u.CJ_NAME != "") .OrderBy(u => u.CJ_NAME).GroupBy(u => new { u.DEPT_NAME, u.DEPT_CODE, u.GWD_NAME, u.GWD_CODE, u.XN_NAME, u.GQ_NAME, u.CJ_NAME }) .Select(g => new VIEW_SYS_DEPT { DEPT_NAME = g.Key.DEPT_NAME, GWD_NAME = g.Key.GWD_NAME, XN_NAME = g.Key.XN_NAME, GQ_NAME = g.Key.GQ_NAME, CJ_NAME = g.Key.CJ_NAME }).ToList(); if (listDEPT_GQ.Count > 0) { string cjname = ""; int m = 1; foreach (VIEW_SYS_DEPT gq in listDEPT_GQ) { if (cjname != gq.CJ_NAME)//如果是新父级,则重新编号 { m = 1; cjname = gq.CJ_NAME; } string gqNum = m < 10 ? "0" + m.ToString() : m.ToString(); string gqcode = DeptCodeMap[gq.DEPT_NAME + "_" + gq.GWD_NAME + "_" + gq.XN_NAME + "_" + gq.CJ_NAME] + gqNum; if (oc.BllSession.ISYS_DEPTService.Entities.Where(u => u.DEPT_CODE == gqcode).Count() == 0) { //如果数据库无此部门编码则添加 list_SYS_DEPT.Add(new SYS_DEPT() //车间 { DEPT_CODE = DeptCodeMap[gq.DEPT_NAME + "_" + gq.GWD_NAME + "_" + gq.XN_NAME + "_" + gq.CJ_NAME] + gqNum, DEPT_NAME = gq.GQ_NAME, PARENT_CODE = DeptCodeMap[gq.DEPT_NAME + "_" + gq.GWD_NAME + "_" + gq.XN_NAME + "_" + gq.CJ_NAME], DEPT_ORDER = 0, DEL_FLAG = "0", STATUS_FLAG = "0", C_ICO = "icon-org", DEPT_FLAG = 0 }); } DeptCodeMap.Add(gq.DEPT_NAME + "_" + gq.GWD_NAME + "_" + gq.XN_NAME + "_" + gq.CJ_NAME + "_" + gq.GQ_NAME, DeptCodeMap[gq.DEPT_NAME + "_" + gq.GWD_NAME + "_" + gq.XN_NAME + "_" + gq.CJ_NAME] + gqNum); m++; } } //人员 List <VIEW_SYS_DEPT> listDEPT_RY = list_VIEW_SYS_DEPT.Where(u => u.NAME != null && u.MOBILE != null && u.NAME != "" && u.MOBILE != "").ToList(); int n = 0; foreach (VIEW_SYS_DEPT member in listDEPT_RY) { if (oc.BllSession.ISYS_MEMBERService.Entities.Where(u => u.MOBILE == member.MOBILE).Count() == 0) { //如果数据库无此手机号则添加 list_SYS_MEMBER.Add(new SYS_MEMBER() //车间 { MEMBER_ID = DateTime.Now.ToString("yyyyMMddHHmmssfff") + n.ToString(), DEPT_CODE = DeptCodeMap[getCode(member)], NAME = member.NAME, MOBILE = member.MOBILE, INTELLIGENCE = member.INTELLIGENCE == ""?"": MemberIntelligenceMap[member.INTELLIGENCE], UPDATE_DATE = DateTime.Now, UPDATE_USER = oc.CurrentUser.USER_NAME, DEL_FLAG = "0", LOCATION_FLAG = "1", JOB = member.JOB }); } n++; } } catch (Exception e) { amm.Msg = "解析错误或资质名称不匹配"; amm.Statu = AjaxStatu.err; } } if (amm.Statu == AjaxStatu.err)//如果不存在 { //amm.Data = errorList; return(ObjToJson.GetToJson(amm, true)); } //业务判断并插入数据库 int returnValue = 0; using (TransactionScope ts = new TransactionScope()) { returnValue = oc.BllSession.ISYS_DEPTService.AddListEntity(list_SYS_DEPT); returnValue = returnValue + oc.BllSession.ISYS_MEMBERService.AddListEntity(list_SYS_MEMBER); ts.Complete(); } if (list_SYS_DEPT.Count == 0 && list_SYS_MEMBER.Count == 0) { returnValue = 1; } if (returnValue > 0) { amm.Statu = AjaxStatu.ok; amm.Msg = "导入成功部门" + list_SYS_DEPT.Count + "-人员" + list_SYS_MEMBER.Count; } else { amm.Statu = AjaxStatu.err; amm.Msg = "导入失败"; } return(ObjToJson.GetToJson(amm, true)); #endregion }
public static string GetPosLevelCheckedTree(string DEPT_CODE, string PARENT_CODE, bool isCheckAll) { string strJson = string.Empty; List <SYS_DEPTANDMEMBER_TEMP> listOrgRy = new List <SYS_DEPTANDMEMBER_TEMP>(); //获取人员 List <SYS_MEMBER> listRyMenu = oc.BllSession.ISYS_MEMBERService.GetListByCondition <string>(m => m.DEL_FLAG == "0" && m.LOCATION_FLAG == "1" && m.DEPT_CODE.StartsWith(DEPT_CODE), m => m.MOBILE) .Select(mb => mb.ToPOCO()).ToList(); //级别 List <SYS_POSLEVEL_DIC> PosLevellist = oc.BllSession.ISYS_POSLEVEL_DICService.Entities.OrderBy(u => u.DIC_ORDER).ToList(); if (listRyMenu.Count > 0) { foreach (SYS_MEMBER ry in listRyMenu) { string icon = "icon-Off-line"; if (ry.MOBILE_STATE == "1") { icon = "icon-status_busy"; } listOrgRy.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = ry.MOBILE, PARENT_CODE = (ry.DEPT_CODE.Length >= 4 ? ry.DEPT_CODE.Substring(0, 4) : ry.DEPT_CODE) + (!PosLevellist.Select(u => u.DIC_ID).Contains(ry.POS_LEVEL) ? "1A" : ry.POS_LEVEL), //如果没有归类(空或者在字典表不存在),则默认到其他 ORGRY_NAME = ry.NAME, ICO = icon, RYMOBILE = ry.MOBILE, STATE = "0"//关闭 }); } } //获取资质 List <SYS_DEPTANDMEMBER_TEMP> listTemp = new List <SYS_DEPTANDMEMBER_TEMP>(); List <string> parList = listOrgRy.Select(u => u.PARENT_CODE).Distinct().ToList(); if (PosLevellist.Count > 0) { foreach (string parcode in parList) { string deptcode = parcode.Substring(0, parcode.Length - 2); string diccode = parcode.Substring(parcode.Length - 2); if (PosLevellist.Where(u => u.DIC_ID.Equals(diccode)).Count() > 0) { SYS_POSLEVEL_DIC dic = PosLevellist.Where(u => u.DIC_ID.Equals(diccode)).FirstOrDefault(); listTemp.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = parcode, PARENT_CODE = deptcode, ORGRY_NAME = dic.DIC_NAME, ICO = dic.DIC_ICON, ORDER = dic.DIC_ORDER, RYMOBILE = string.Empty, //parcode, STATE = "0" //关闭 }); } } } listOrgRy.AddRange(listTemp.OrderBy(u => u.ORDER)); //获得组织 List <SYS_DEPT> listMenu = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && (m.PARENT_CODE.StartsWith(DEPT_CODE) || m.DEPT_CODE == DEPT_CODE) && m.DEPT_CODE.Length <= 4) .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE).ToList(); if (listMenu.Count > 0) { foreach (SYS_DEPT org in listMenu) { listOrgRy.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = org.DEPT_CODE, PARENT_CODE = org.PARENT_CODE, ORGRY_NAME = org.DEPT_NAME, ICO = org.C_ICO, RYMOBILE = "", STATE = org.STATUS_FLAG//0关闭 }); } } List <ZTreeNode> listTreeNodes = SYS_DEPTANDMEMBER_TEMP.ConvertZTreeNodes(listOrgRy, PARENT_CODE, DEPT_CODE, isCheckAll); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }
public ActionResult GetMyMenu(string id) { string strJson = "[]"; //if (Constant.GISMenuID.Split(',').Contains(id)) //{ // //如果是获取GIS二级菜单 // List<SYS_MENU> listMenu = oc.BllSession.ISYS_MENUService.Entities // .Where(m => m.MENU_LEVEL != Constant.MyMenuLevel && m.PARENT_ID.StartsWith(id)) // .OrderBy(m => m.MENU_ORDER).ToList();// oc.BllSession.ISYS_MENUService.Entities.ToList();//.GetListByCondition<decimal?>(null, ma => ma.MENU_LEVEL).Select(mb => mb.ToPOCO()).ToList(); // if (listMenu.Count > 0) // { // List<EasyUITreeNode> listTreeNodes = SYS_MENU.ConvertTreeNodes(listMenu, id); // strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); // } //} //else //{ //根据选择的一级菜单找对应模块默认打开的三级页面 string parID = id.Substring(0, 2); SYS_MENU parMenu = oc.BllSession.ISYS_MENUService.Entities.Where(u => u.MENU_ID.Equals(parID)).FirstOrDefault(); string twoMenuID = string.Empty; string threeMenuID = string.Empty; try { if (!string.IsNullOrEmpty(parMenu.DEFMENU_ID)) { twoMenuID = parMenu.DEFMENU_ID.Substring(0, 6); threeMenuID = parMenu.DEFMENU_ID.Substring(0, 8); } } catch { twoMenuID = string.Empty; threeMenuID = string.Empty; } List <SYS_MENU> listMenu = oc.UserMenuPermission.Where(m => m.MENU_LEVEL != Constant.MyMenuLevel && m.PARENT_ID.StartsWith(id)).OrderBy(m => m.MENU_LEVEL) .ThenBy(m => m.MENU_ORDER).ToList();// oc.BllSession.ISYS_MENUService.Entities.ToList();//.GetListByCondition<decimal?>(null, ma => ma.MENU_LEVEL).Select(mb => mb.ToPOCO()).ToList(); if (listMenu.Count > 0) { if (string.IsNullOrEmpty(twoMenuID)) { SYS_MENU firstThreeMenu = listMenu.Where(u => u.MENU_LEVEL == 3).FirstOrDefault(); if (firstThreeMenu != null) { twoMenuID = firstThreeMenu.MENU_ID.Substring(0, 6); threeMenuID = firstThreeMenu.MENU_ID; } } List <EasyUITreeNode> listTreeNodes = SYS_MENU.ConvertTreeNodes(listMenu, id); foreach (EasyUITreeNode node in listTreeNodes) { if (node.id.Equals(twoMenuID)) { node.isdefuopen = "Y"; } else { node.isdefuopen = "N"; } foreach (EasyUITreeNode Childnode in node.children) { if (Childnode.id.Equals(threeMenuID)) { Childnode.isdefuopen = "Y"; } else { Childnode.isdefuopen = "N"; } } } strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); } //} return(Content(strJson)); }
/// <summary> /// 获取气象监测线名树 /// </summary> /// <param name="DEPT_CODE"></param> /// <param name="PARENT_CODE"></param> /// <returns></returns> public static string GetWeatherLineTree(string DEPT_CODE, string PARENT_CODE) { Dictionary <string, string> deptDict = new Dictionary <string, string>(); if (DEPT_CODE.Length == 2) { IQueryable <SYS_DEPT> dic = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_CODE.Length <= 4); foreach (var item in dic) { deptDict.Add(item.DEPT_CODE, item.DEPT_NAME); } } string strJson = string.Empty; List <SYS_DEPTANDMEMBER_TEMP> listorgHost = new List <SYS_DEPTANDMEMBER_TEMP>(); //获取主机 List <BROKENRAIL_BDATA_SECTION> listHost = oc.BllSession.IBROKENRAIL_BDATA_SECTIONService .GetListByCondition <string>(g => g.DEPT_CODE.StartsWith(DEPT_CODE), g => g.SECTION_ID).ToList(); listHost = listHost.OrderBy(o => o.START_MILE).ToList(); //cwb List <BROKENRAIL_BDATA_DEVICE> listDevice = oc.BllSession.IBROKENRAIL_BDATA_DEVICEService.Entities.Where(o => o.TYPE == "主机").ToList(); if (listHost.Count > 0) { foreach (BROKENRAIL_BDATA_SECTION host in listHost) { string head = string.Empty; if (DEPT_CODE.Length == 2) { head = deptDict[host.DEPT_CODE]; } listorgHost.Add(new SYS_DEPTANDMEMBER_TEMP { ORGRY_CODE = host.SECTION_ID, PARENT_CODE = host.LINE_NAME, ORGRY_NAME = host.SECTION_NAME, ICO = "icon-drive", RYMOBILE = head + "(" + GetToKDESC(host.START_MILE) + "~" + GetToKDESC(host.END_MILE) + ")", STATE = "0", //cwb // PHONE = host.SECTION_ID//oc.BllSession.IBROKENRAIL_BDATA_DEVICEService.Entities.Where(o => o.SECTION_ID == host.SECTION_ID && o.TYPE == "主机").FirstOrDefault().POINT_NO PHONE = listDevice.Where(o => o.SECTION_ID == host.SECTION_ID).FirstOrDefault().POINT_NO }); } } List <string> line = oc.BllSession.IBROKENRAIL_BDATA_SECTIONService.Entities.Select(o => o.LINE_NAME).Distinct().ToList(); IQueryable <T_JOB_LINE> listLineMenu = oc.BllSession.IT_JOB_LINEService.Entities.Where(o => o.LINE_DEPTCODE.Contains(DEPT_CODE)); foreach (var item in listLineMenu) { if (!line.Contains(item.LINE_NAME)) { line.Insert(line.Count, item.LINE_NAME); } } SYS_DEPT dept = oc.BllSession.ISYS_DEPTService.Entities.Where(m => m.DEL_FLAG == "0" && m.DEPT_CODE == DEPT_CODE).FirstOrDefault(); //List<SYS_DEPT> listMenu = oc.BllSession.ISYS_DEPTService.Entities // .Where(m => m.DEL_FLAG == "0" && (m.PARENT_CODE.StartsWith(DEPT_CODE) || m.DEPT_CODE == DEPT_CODE)) // .OrderBy(m => m.DEPT_ORDER).ThenBy(m => m.DEPT_CODE).ToList(); if (dept != null) { listorgHost.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = dept.DEPT_CODE, PARENT_CODE = dept.PARENT_CODE, ORGRY_NAME = dept.DEPT_NAME, ICO = "icon-DepartMent", RYMOBILE = "", STATE = "0"//0关闭 }); if (listLineMenu.Count() > 0) { foreach (var org in line) { listorgHost.Add(new SYS_DEPTANDMEMBER_TEMP() { ORGRY_CODE = org, PARENT_CODE = DEPT_CODE, ORGRY_NAME = org, ICO = "icon-DepartMent", RYMOBILE = "", STATE = "0"//0关闭 }); } } } List <ZTreeNode> listTreeNodes = SYS_DEPTANDMEMBER_TEMP.ConvertZTreeNodes(listorgHost, PARENT_CODE, DEPT_CODE, true); strJson = ObjToJson.GetToJson(listTreeNodes).Replace("Checked", "checked"); return(strJson); }
// // 摘要: // 在过程请求授权时调用。 // // 参数: // filterContext: // 筛选器上下文,它封装有关使用 System.Web.Mvc.AuthorizeAttribute 的信息。 // // 异常: // System.ArgumentNullException: // filterContext 参数为 null。 public override void OnAuthorization(AuthorizationContext filterContext) { /** * 如果请求的区域包含area并且area的名称等于SYSs * 那么就进行权限验证 * */ if (filterContext.RouteData.DataTokens.Keys.Contains("area") && (filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "sys" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "gate" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "gis" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "job" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "material" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "rule" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "scripts" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "rain" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "tool" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "rail" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "car" || filterContext.RouteData.DataTokens["area"].ToString().ToLower() == "repair" )) { ///** // * 验证用户是否登录 // * */ if (!Model_SYS_USER.IsLogin()) { ///如果没有登录那么就跳转到登录页面 filterContext.Result = new BaseController().Redirect("/Home/Login?msg=noLogin", filterContext.ActionDescriptor, AjaxStatu.nologin); } else { if (!AuthorizeIs(filterContext.HttpContext)) { filterContext.Result = new BaseController().Redirect("/Home/Login?msg=noLogin", filterContext.ActionDescriptor, AjaxStatu.none); } else { /** * Action方法本身及它所属控制器都没有定义Skip特性 * 那么就可以进行权限验证 * */ if (!filterContext.ActionDescriptor.AttributeExists <Common.Attributes.SkipAttribute>(false) && !filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(Common.Attributes.SkipAttribute), false)) { //验证该登录用户是否有访问该页面的权限 string strAreaName = filterContext.RouteData.DataTokens["area"].ToString().ToLower(); string strControllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToLower(); string strActionName = filterContext.ActionDescriptor.ActionName.ToLower(); if (strActionName == "index") { string[] url = filterContext.HttpContext.Request.FilePath.Split('/'); if (url.Length > 4) { for (int i = 4; i < url.Length; i++) { strActionName = strActionName + "/" + url[i]; } } } string strHttpMethod = filterContext.HttpContext.Request.HttpMethod; HttpMethod httpMethod = strHttpMethod.ToLower().Equals("get") ? HttpMethod.Get : strHttpMethod.ToLower().Equals("post") ? HttpMethod.Post : HttpMethod.HEAD; if (!Model_SYS_MENU.HasPermission(strAreaName, strControllerName, strActionName, httpMethod)) { filterContext.Result = new BaseController().Redirect("/Home/Login?msg=noPermission", filterContext.ActionDescriptor, AjaxStatu.noperm); } else { if (strActionName.ToLower() == "list" && filterContext.HttpContext.Request["page"] != null && filterContext.HttpContext.Request["rows"] != null) { string pageIndex = filterContext.HttpContext.Request["page"].ToString(); string pageSize = filterContext.HttpContext.Request["rows"].ToString(); if (pageIndex == "0" && pageSize == "0") { filterContext.Result = ObjToJson.GetToJson(null, 0, true); } } } } } } } }