/// <summary> /// 根据查询条件和Hql查询 /// </summary> /// <param name="condition"></param> /// <returns></returns> public static T[] FindAll(HqlSearchCriterion criterion, string editStatus, params ICriterion[] crits) { IList <ICriterion> critList = crits.ToList(); critList.Add(Expression.Eq("EditStatus", editStatus)); return(criterion.FindAll <T>(critList.ToArray())); }
string code = String.Empty; // 编码 #endregion #region 构造函数 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); type = RequestData.Get <string>("type"); code = RequestData.Get <string>("code"); DynamicAuthCatalog dac = null; // 动态权限类型 SearchCriterion sc = new HqlSearchCriterion(); SearchCriterion.SetOrder("SortIndex"); SearchCriterion.SetOrder("CreatedDate"); SearchCriterion.AddSearch("EditStatus", "G", SearchModeEnum.Like); // 只显示允许授权的节点 if (type == "catalog") { if (String.IsNullOrEmpty(code) && !String.IsNullOrEmpty(id)) { dac = DynamicAuthCatalog.Find(id); code = dac.Code; } if (!String.IsNullOrEmpty(code)) { SearchCriterion.AddSearch("CatalogCode", code); SearchCriterion.AddSearch("ParentID", SingleSearchModeEnum.IsNull); ents = DynamicAuthRule.FindAll(SearchCriterion); if (dac == null) { dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", code)); } } } else if (!String.IsNullOrEmpty(id)) { SearchCriterion.AddSearch("ParentID", id); ents = DynamicAuthRule.FindAll(SearchCriterion); DynamicAuth da = DynamicAuth.Find(id); dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", da.CatalogCode)); } this.PageState.Add("EntList", ents); if (!IsAsyncRequest) { if (dac != null) { IList <DynamicPermissionCatalog> dpcs = dac.AllowGrantPermissionCatalog; this.PageState.Add("PCatalogList", dpcs); } } }
/// <summary> /// 选择操作 /// </summary> private void DoSelect() { DynamicAuthCatalog dac = null; // 动态权限类型 SearchCriterion sc = new HqlSearchCriterion(); SearchCriterion.SetOrder("SortIndex"); SearchCriterion.SetOrder("CreatedDate"); SearchCriterion.AddSearch("EditStatus", "G", SearchModeEnum.Like); // 只显示允许授权的节点 if (type == "catalog") { if (String.IsNullOrEmpty(code) && !String.IsNullOrEmpty(id)) { dac = DynamicAuthCatalog.Find(id); code = dac.Code; } if (!String.IsNullOrEmpty(code)) { SearchCriterion.AddSearch("CatalogCode", code); SearchCriterion.AddSearch("ParentID", SingleSearchModeEnum.IsNull); ents = DynamicAuthRule.FindAll(SearchCriterion); if (dac == null) { dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", code)); } } } else if (!String.IsNullOrEmpty(id)) { SearchCriterion.AddSearch("ParentID", id); ents = DynamicAuthRule.FindAll(SearchCriterion); DynamicAuth da = DynamicAuth.Find(id); dac = DynamicAuthCatalog.FindFirst(Expression.Eq("Code", da.CatalogCode)); } this.PageState.Add("EntList", ents); if (!IsAsyncRequest) { if (dac != null) { IList <DynamicPermissionCatalog> dpcs = dac.AllowGrantPermissionCatalog; this.PageState.Add("PCatalogList", dpcs); this.PageState.Add("AllowOperation", dac.GetAllowOperations()); // 允许的操作 } this.PageState.Add("OpDivChar", DynamicOperations.DivChar); // 操作分割符 } }
string code = String.Empty; // 对象类型 #endregion #region 构造函数 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { op = RequestData.Get <string>("op"); id = RequestData.Get <string>("id"); code = RequestData.Get <string>("code"); if (IsAsyncRequest) { DynamicAuth ent = null; switch (this.RequestAction) { case RequestActionEnum.Read: case RequestActionEnum.Query: case RequestActionEnum.Default: if (SearchCriterion.Orders.Count <= 0) { SearchCriterion.SetOrder("SortIndex"); SearchCriterion.SetOrder("CreatedDate"); } SearchCriterion.AddSearch("CatalogCode", code); SearchCriterion.AddSearch("EditStatus", SingleSearchModeEnum.IsNotNull); SearchCriterion.AddSearch("EditStatus", "", SearchModeEnum.NotEqual); if (String.IsNullOrEmpty(id)) { SearchCriterion.AddSearch("ParentID", SingleSearchModeEnum.IsNull); } else { SearchCriterion.AddSearch("ParentID", id); } ents = DynamicAuthRule.FindAll(SearchCriterion); break; case RequestActionEnum.Delete: ent = DynamicAuth.Find(id); ent.DoDelete(); this.SetMessage("删除成功!"); break; } this.PageState.Add("EntList", ents); } else { SearchCriterion sc = new HqlSearchCriterion(); sc.SetOrder("SortIndex"); sc.SetOrder("CreatedDate"); DynamicAuthCatalog[] entCatalogs = DynamicAuthCatalogRule.FindAll(sc); this.PageState.Add("EntCatalogList", entCatalogs); } }
SearchModeEnum tagschmode = SearchModeEnum.Like; // 扩展信息查询方式 #endregion #region 构造函数 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id", String.Empty); ids = RequestData.GetList <string>("ids"); pids = RequestData.GetList <string>("pids"); code = RequestData.Get <string>("code", String.Empty); showroot = RequestData.Get <string>("showroot", String.Empty); tag = RequestData.Get <string>("tag", String.Empty); string tagschmodestr = RequestData.Get <string>("tagschmode", String.Empty); tagschmode = ObjectHelper.GetEnum <SearchModeEnum>(tagschmodestr, SearchModeEnum.Like); SysEnumeration ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SysEnumeration>(); ent.ParentID = String.IsNullOrEmpty(ent.ParentID) ? null : ent.ParentID; ent.Update(); this.SetMessage("更新成功!"); break; default: if (RequestActionString == "batchdelete") { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { SysEnumeration.DoBatchDelete(idList.ToArray()); } } else { // 构建查询表达式 SearchCriterion sc = new HqlSearchCriterion(); // sc.SetOrder("SortIndex"); sc.SetOrder("CreatedDate"); ICriterion crit = null; if (RequestActionString == "querychildren") { if (ids != null && ids.Count > 0 || pids != null && pids.Count > 0) { if (ids != null && ids.Count > 0) { IEnumerable <string> distids = ids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); crit = Expression.In(SysEnumeration.Prop_EnumerationID, distids.ToArray()); } if (pids != null && pids.Count > 0) { IEnumerable <string> dispids = pids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); if (crit != null) { crit = SearchHelper.UnionCriterions(crit, Expression.In(SysEnumeration.Prop_ParentID, dispids.ToArray())); } else { crit = Expression.In(SysEnumeration.Prop_ParentID, dispids.ToArray()); } } } } else { ICriterion tagCirt = null; if (!String.IsNullOrEmpty(tag)) { HqlCommonSearchCriterionItem tagCritItem = new HqlCommonSearchCriterionItem(SysEnumeration.Prop_Tag, tag, tagschmode); tagCirt = tagCritItem.GetCriterion(); } if (!String.IsNullOrEmpty(code)) { SysEnumeration tent = SysEnumeration.FindFirstByProperties(SysEnumeration.Prop_Code, code); crit = SearchHelper.IntersectCriterions( Expression.Eq(SysEnumeration.Prop_ParentID, tent.EnumerationID), tagCirt); if (!String.IsNullOrEmpty(showroot) && showroot != "0" && showroot.ToLower() != "false") { crit = SearchHelper.UnionCriterions( crit, Expression.Eq(SysEnumeration.Prop_EnumerationID, tent.EnumerationID)); } this.PageState.Add("Root", tent); } else { crit = SearchHelper.UnionCriterions(Expression.IsNull(SysEnumeration.Prop_ParentID), Expression.Eq(SysEnumeration.Prop_ParentID, String.Empty)); crit = SearchHelper.IntersectCriterions(crit, tagCirt); } } ents = SysEnumerationRule.FindAll(sc, crit); this.PageState.Add("DtList", ents); } break; } }
/// <summary> /// 根据查询条件查询 /// </summary> /// <param name="condition"></param> /// <returns></returns> public static T[] FindAll(HqlSearchCriterion criterion, string editStatus) { return(criterion.FindAll <T>(Expression.Eq("EditStatus", editStatus))); }
IList <string> pids = null; // 父节点列表 #endregion #region 构造函数 #endregion #region ASP.NET 事件 protected void Page_Load(object sender, EventArgs e) { id = RequestData.Get <string>("id", String.Empty); ids = RequestData.GetList <string>("ids"); pids = RequestData.GetList <string>("pids"); SysParameterCatalog ent = null; switch (this.RequestAction) { case RequestActionEnum.Update: ent = this.GetMergedData <SysParameterCatalog>(); ent.ParentID = String.IsNullOrEmpty(ent.ParentID) ? null : ent.ParentID; ent.Update(); this.SetMessage("更新成功!"); break; default: if (RequestActionString == "batchdelete") { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { SysParameterCatalog.DoBatchDelete(idList.ToArray()); } } else { // 构建查询表达式 SearchCriterion sc = new HqlSearchCriterion(); // sc.SetOrder("SortIndex"); sc.SetOrder("CreatedDate"); ICriterion crit = null; if (RequestActionString == "querychildren") { if (ids != null && ids.Count > 0 || pids != null && pids.Count > 0) { if (ids != null && ids.Count > 0) { IEnumerable <string> distids = ids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); crit = Expression.In("ParameterCatalogID", distids.ToArray()); } if (pids != null && pids.Count > 0) { IEnumerable <string> dispids = pids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); if (crit != null) { crit = SearchHelper.UnionCriterions(crit, Expression.In("ParentID", dispids.ToArray())); } else { crit = Expression.In("ParentID", dispids.ToArray()); } } } } else { crit = SearchHelper.UnionCriterions(Expression.IsNull("ParentID"), Expression.Eq("ParentID", String.Empty)); } if (crit != null) { ents = SysParameterCatalogRule.FindAll(sc, crit); } else { ents = SysParameterCatalogRule.FindAll(sc); } this.PageState.Add("DtList", ents); } break; } }
/// <summary> /// 选择数据 /// </summary> private void DoSelect() { // 构建查询表达式 SearchCriterion sc = new HqlSearchCriterion(); sc.SetOrder("SortIndex"); ICriterion crit = null; if (RequestActionString == "querychildren") { if (ids != null && ids.Count > 0 || pids != null && pids.Count > 0) { if (ids != null && ids.Count > 0) { IEnumerable <string> distids = ids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); crit = Expression.In(A_TaskWBS.Prop_Id, distids.ToArray()); } if (pids != null && pids.Count > 0) { IEnumerable <string> dispids = pids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); if (crit != null) { crit = SearchHelper.UnionCriterions(crit, Expression.In(A_TaskWBS.Prop_ParentID, dispids.ToArray())); } else { crit = Expression.In(A_TaskWBS.Prop_ParentID, dispids.ToArray()); string pid = dispids.ToArray()[0]; if (pid == "1437f360-6937-409b-9548-964661e6c27c") { string test = pid; } //不是自己责任人的只能看到属于自己的(暂时屏蔽掉,有权限看到自己的子节点) /*if (A_TaskWBS.Find(pid).DutyId.IndexOf(this.UserInfo.UserID) < 0) * { * //判断是否父节点有权限,有全部输出 * //A_TaskWBS tp = A_TaskWBS.Find(pid); * string sqlall = " select Id,Path from " + db + "..A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%'"; * DataTable dtall = DataHelper.QueryDataTable(sqlall); * string checksql = "select Id from " + db + "..A_TaskWBS where ParentId='" + pid + "' and "; * string rules = ""; * foreach (DataRow row in dtall.Rows) * { * if (row["Path"] != null && row["Path"].ToString() != "") * rules += " Path like '%" + row["Path"] + "%' or"; * } * if (rules != "") rules = rules.Substring(0, rules.Length - 2); * if (DataHelper.QueryDataTable(checksql + "(" + rules + ")").Rows.Count == 0) * { * //判断有权限的子节点梯队 * string sqlIds = " select Id,Path from " + db + "..A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%' and Path like '%" + pid + "%'"; * DataTable dt = DataHelper.QueryDataTable(sqlIds); * string cids = ""; * string cpids = ""; * foreach (DataRow row in dt.Rows) * { * cids += row["Path"].ToString() + '.'; * cpids += " or Path like '%" + row["Path"].ToString() + "%'"; * } * cids = cids.TrimEnd('.').Replace(".", "','"); * crit = Expression.Sql(" ParentID = '" + pid + "' and ( Id in ('" + cids + "') " + cpids + " )");//SearchHelper.IntersectCriterions(crit); * * } * }*/ } } } } else { if (!String.IsNullOrEmpty(year)) { crit = Expression.Eq(A_TaskWBS.Prop_Year, year); /*EasyDictionary es = SysEnumeration.GetEnumDict("AimType"); * foreach (var at in es) * { * if (!this.RequestData.Get<bool>(at.Value.ToString())) * { * crit = SearchHelper.IntersectCriterions(crit, Expression.Not(Expression.Eq(A_TaskWBS.Prop_TaskType, at.Value))); * } * }*/ } if (this.Request.QueryString["Type"] != null && this.Request.QueryString["Type"].ToString() != "") { crit = SearchHelper.UnionCriterions(Expression.IsNull(A_TaskWBS.Prop_ParentID), Expression.Eq(A_TaskWBS.Prop_ParentID, String.Empty)); //crit = SearchHelper.IntersectCriterions(crit,Expression.Eq(A_TaskWBS.Prop_Type, this.Request.QueryString["Type"].ToString())); } else { /*crit = SearchHelper.UnionCriterions(Expression.IsNull(A_TaskWBS.Prop_ParentID), * Expression.Eq(A_TaskWBS.Prop_ParentID, String.Empty)); * //crit = Expression.Like(A_TaskWBS.Prop_DutyId, this.UserInfo.UserID);*/ //先屏蔽掉一进来自己只能看到自己的限制,根据权限过滤查询. //crit = SearchHelper.IntersectCriterions(crit, Expression.Sql(" Id in (select distinct SUBSTRING(isnull(Path,Id),0,37) from A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%')")); } crit = CheckProperty(crit); } if (crit != null) { ents = A_TaskWBS.FindAll(sc, crit); } else { ents = A_TaskWBS.FindAll(sc); } if (ents != null && ents.Length != 0) { this.PageState.Add("DtList", ents.OrderBy(en => en.Code)); } }
private void DoSelect() { SearchCriterion sc = new HqlSearchCriterion(); // 构建查询表达式 sc.SetOrder("SortIndex"); sc.SetOrder("Code"); ICriterion crit = null; if (RequestActionString == "querychildren") { if (ids != null && ids.Count > 0 || pids != null && pids.Count > 0) { if (ids != null && ids.Count > 0) { IEnumerable <string> distids = ids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); crit = Expression.In(A_TaskWBS.Prop_Id, distids.ToArray()); } if (pids != null && pids.Count > 0) { IEnumerable <string> dispids = pids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); if (crit != null) { crit = SearchHelper.UnionCriterions(crit, Expression.In(A_TaskWBS.Prop_ParentID, dispids.ToArray())); } else { crit = Expression.In(A_TaskWBS.Prop_ParentID, dispids.ToArray()); string pid = dispids.ToArray()[0]; if (pid == "1437f360-6937-409b-9548-964661e6c27c") { string test = pid; } //不是自己责任人的只能看到属于自己的(暂时屏蔽掉,有权限看到自己的子节点) /*if (A_TaskWBS.Find(pid).DutyId.IndexOf(this.UserInfo.UserID) < 0) * { * //判断是否父节点有权限,有全部输出 * //A_TaskWBS tp = A_TaskWBS.Find(pid); * string sqlall = " select Id,Path from " + db + "..A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%'"; * DataTable dtall = DataHelper.QueryDataTable(sqlall); * string checksql = "select Id from " + db + "..A_TaskWBS where ParentId='" + pid + "' and "; * string rules = ""; * foreach (DataRow row in dtall.Rows) * { * if (row["Path"] != null && row["Path"].ToString() != "") * rules += " Path like '%" + row["Path"] + "%' or"; * } * if (rules != "") rules = rules.Substring(0, rules.Length - 2); * if (DataHelper.QueryDataTable(checksql + "(" + rules + ")").Rows.Count == 0) * { * //判断有权限的子节点梯队 * string sqlIds = " select Id,Path from " + db + "..A_TaskWBS where DutyId like '%" + this.UserInfo.UserID + "%' and Path like '%" + pid + "%'"; * DataTable dt = DataHelper.QueryDataTable(sqlIds); * string cids = ""; * string cpids = ""; * foreach (DataRow row in dt.Rows) * { * cids += row["Path"].ToString() + '.'; * cpids += " or Path like '%" + row["Path"].ToString() + "%'"; * } * cids = cids.TrimEnd('.').Replace(".", "','"); * crit = Expression.Sql(" ParentID = '" + pid + "' and ( Id in ('" + cids + "') " + cpids + " )");//SearchHelper.IntersectCriterions(crit); * * } * }*/ } } } } else { crit = Expression.Eq(A_TaskWBS.Prop_Year, year); if (this.Request.QueryString["Type"] != null && this.Request.QueryString["Type"].ToString() != "") { crit = SearchHelper.UnionCriterions(Expression.IsNull(A_TaskWBS.Prop_ParentID), Expression.Eq(A_TaskWBS.Prop_ParentID, String.Empty)); } else { string sqlC = " Id in (select distinct SUBSTRING(isnull(Path,Id),0,37) from BJKY_IntegratedManage..A_TaskWBS where ((DutyId like '%{0}%' or UserIds like '%{0}%') and State='1') or CreateId='{0}')"; sqlC = string.Format(sqlC, UserInfo.UserID); crit = SearchHelper.IntersectCriterions(crit, Expression.Sql(sqlC)); } } if (crit != null) { ents = A_TaskWBS.FindAll(sc, SearchHelper.IntersectCriterions(crit, Expression.Eq(A_TaskWBS.Prop_Year, year))); } else { ents = A_TaskWBS.FindAll(sc); } if (ents != null && ents.Length != 0) { this.PageState.Add("DtList", ents); } }
/// <summary> /// 选择数据 /// </summary> private void DoSelect() { // 构建查询表达式 SearchCriterion sc = new HqlSearchCriterion(); sc.SetOrder("SortIndex"); ICriterion crit = null; if (RequestActionString == "querychildren") { if (ids != null && ids.Count > 0 || pids != null && pids.Count > 0) { if (ids != null && ids.Count > 0) { IEnumerable <string> distids = ids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); crit = Expression.In(SysEnumeration.Prop_EnumerationID, distids.ToArray()); } if (pids != null && pids.Count > 0) { IEnumerable <string> dispids = pids.Distinct().Where(tent => !String.IsNullOrEmpty(tent)); if (crit != null) { crit = SearchHelper.UnionCriterions(crit, Expression.In(SysEnumeration.Prop_ParentID, dispids.ToArray())); } else { crit = Expression.In(SysEnumeration.Prop_ParentID, dispids.ToArray()); } } } } else { if (!String.IsNullOrEmpty(code)) { SysEnumeration tent = SysEnumeration.FindFirstByProperties(SysEnumeration.Prop_Code, code); crit = Expression.Eq(SysEnumeration.Prop_ParentID, tent.EnumerationID); } else { crit = SearchHelper.UnionCriterions(Expression.IsNull(SysEnumeration.Prop_ParentID), Expression.Eq(SysEnumeration.Prop_ParentID, String.Empty)); } } if (crit != null) { ents = SysEnumerationRule.FindAll(sc, crit); } else { ents = SysEnumerationRule.FindAll(sc); } if (ents != null && ents.Length != 0) { this.PageState.Add("DtList", ents.OrderBy(v => v.SortIndex)); } }