/// <summary> /// 根据上一次查询条件重新读入数据 /// 第一条记录设置不变 /// </summary> public virtual void ReloadData() { //// 还没查找过,不能刷新 //if (m_needFindConddition && !m_findConditionLoaded) // return; //if (m_needSearchExpression) //{ SearchHistoryInfo his = GetHistory(0); // his.Expression = string.Empty 代表查询条件为空,当时已经查询过 if (his != null && his.IsCurrentSession && his.Expression != null) { LoadData(SearchExpression.Parse(his.Expression), SearchOrder.Parse(his.Order)); } // 不过无查询条件,不刷新 //else //{ // LoadData(); //} //} //else //{ // LoadData(new List<ISearchExpression>(), null, this.FirstResult); // return true; //} }
//private bool m_needSearchExpression = true; ///// <summary> ///// 是否需要查找条件(如需要,刷新的时候必须要现有条件) ///// </summary> //protected bool NeedSearchConddition //{ // get { return m_needSearchExpression; } // set { m_needSearchExpression = value; } //} /// <summary> /// 重新读入当前行 /// </summary> public void ReloadItem(int idx) { //if (this.DisplayManager.CurrentItem == null) // return; if (this.DisplayManager.EntityInfo == null) { return; } if (idx < 0 || idx >= this.DisplayManager.Count) { return; } object entity = this.DisplayManager.Items[idx]; object id = EntityScript.GetPropertyValue(entity, this.DisplayManager.EntityInfo.IdName); IList list = this.GetData(SearchExpression.Eq(this.DisplayManager.EntityInfo.IdName, id), null) as IList; System.Diagnostics.Debug.Assert(list.Count <= 1); if (list.Count == 0) { return; } else if (list.Count == 1) { this.DisplayManager.Items[idx] = list[0]; } }
/// <summary> /// 自动填充查找条件然后查找 /// </summary> public void LoadDataAccordSearchControls() { IList <ISearchExpression> searchExpressions; IList <ISearchOrder> searchOrders; FillSearchConditions(out searchExpressions, out searchOrders); LoadData(SearchExpression.ToSingle(searchExpressions), searchOrders); }
/// <summary> /// 根据可读字符串得到查询条件 /// </summary> /// <param name="searchExpression"></param> /// <returns></returns> public static IList <ISearchExpression> ParseToList(string searchExpression) { IList <ISearchExpression> ret = new List <ISearchExpression>(); ISearchExpression exp = SearchExpression.Parse(searchExpression); if (exp != null) { ret.Add(exp); } return(ret); }
/// <summary> /// 读入Entity Schema,使Grid不读入数据时就能显示框架 /// </summary> public virtual IEnumerable GetSchema() { int saveMaxResult = this.MaxResult; this.MaxResult = 0; this.FirstResult = 0; IEnumerable ret = GetData(SearchExpression.False(), null); this.MaxResult = saveMaxResult; return(ret); }
/// <summary> /// List To One /// </summary> /// <param name="searchExpressions"></param> /// <returns></returns> public static ISearchExpression ToSingle(IList <ISearchExpression> searchExpressions) { if (searchExpressions == null || searchExpressions.Count == 0) { return(null); } ISearchExpression se = searchExpressions[0]; for (int i = 1; i < searchExpressions.Count; ++i) { se = SearchExpression.And(se, searchExpressions[i]); } return(se); }
/// <summary> /// 把Expression列表转化为单一Expression(use and) /// </summary> /// <param name="exps"></param> /// <returns></returns> public static ISearchExpression ConvertListToOne(IList <ISearchExpression> exps) { if (exps.Count == 0) { return(null); } ISearchExpression exp = exps[0]; for (int i = 1; i < exps.Count; ++i) { exp = SearchExpression.And(exp, exps[i]); } return(exp); }
/// <summary> /// /// </summary> /// <param name="sm"></param> /// <param name="searchExpression"></param> /// <param name="searchOrders"></param> public static void FillSearchAdditionals(this ISearchManager sm, ref ISearchExpression searchExpression, ref IList <ISearchOrder> searchOrders) { if (!string.IsNullOrEmpty(sm.AdditionalSearchExpression)) { searchExpression = SearchExpression.And(searchExpression, SearchExpression.Parse(sm.AdditionalSearchExpression)); } if (!string.IsNullOrEmpty(sm.AdditionalSearchOrder)) { if (searchOrders == null) { searchOrders = new List <ISearchOrder>(); } foreach (var i in SearchOrder.Parse(sm.AdditionalSearchOrder)) { searchOrders.Add(i); } } }
/// <summary> /// SetHistory /// </summary> /// <param name="searchExpression"></param> /// <param name="searchOrders"></param> /// <param name="isCurrent"></param> private SearchHistoryInfo SetHistory(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders, bool isCurrent) { string nowExpression = SearchExpression.ToString(searchExpression); int existIdx = -1; // 发现有重复的也一样添加,因为翻页用到历史里的最近一条(只和最近一条比较) for (int i = 0; i < 1; ++i) { if (m_searchHistoryInfos[i] != null && m_searchHistoryInfos[i].Expression == nowExpression) { existIdx = i; break; } } if (existIdx == -1) { //historySearchExpressions[historyNow] = SearchExpression.ToString(searchExpressions); //historySearchOrders[historyNow] = SearchOrder.ToString(searchOrders); //historyNow = (historyNow + 1) % historyCnt; for (int i = historyCnt - 1; i > 0; --i) { m_searchHistoryInfos[i] = m_searchHistoryInfos[i - 1]; } m_searchHistoryInfos[0] = new SearchHistoryInfo(SearchExpression.ToString(searchExpression), SearchOrder.ToString(searchOrders), isCurrent); return(m_searchHistoryInfos[0]); } else { m_searchHistoryInfos[existIdx].IsCurrentSession = isCurrent; return(m_searchHistoryInfos[existIdx]); } }
/// <summary> /// /// </summary> /// <param name="propertyName"></param> /// <param name="value"></param> /// <returns></returns> public static ISearchExpression NotGInG(string propertyName, object value) { return(SearchExpression.Not(new SimpleExpression(propertyName, value, SimpleOperator.GInG))); }
/// <summary> /// 按照自定义规则按照地址导航程序到某个界面 /// http://cd/{action}/exp={exp}&order={order}&pos={pos} /// http://cd/action/查询统计_人员单位/?exp=编号 = 100000&order=编号&pos=1 /// </summary> /// <param name="app"></param> /// <param name="address"></param> public static void NavigateTo(this IApplication app, string address) { if (string.IsNullOrEmpty(address) || !address.StartsWith(s_addressHeader)) { return; } string content = address.Substring(s_addressHeader.Length); if (!content.Contains("action/")) { content = Decrypt(content); address = s_addressHeader + content; } UriTemplate template = new UriTemplate("action/{action}/?exp={exp}&order={order}&pos={pos}"); Uri baseAddress = new Uri(s_addressHeader + SystemConfiguration.ApplicationName); Uri fullUri = new Uri(address); // Match a URI to a template UriTemplateMatch results = template.Match(baseAddress, fullUri); if (results != null && results.BaseUri == baseAddress) { try { IDisplayManagerContainer dmC = app.ExecuteAction(results.BoundVariables["action"]) as IDisplayManagerContainer; if (dmC == null) { return; } if (dmC.DisplayManager != null && dmC.DisplayManager.SearchManager != null) { var t = results.BoundVariables["first"]; if (t != null) { int?first = Feng.Utils.ConvertHelper.ToInt(t); if (first.HasValue) { dmC.DisplayManager.SearchManager.FirstResult = first.Value; } } t = results.BoundVariables["count"]; if (t != null) { int?count = Feng.Utils.ConvertHelper.ToInt(t); if (count.HasValue) { dmC.DisplayManager.SearchManager.MaxResult = count.Value; } } t = results.BoundVariables["exp"]; if (t != null) { var exp = SearchExpression.Parse(t); var order = SearchOrder.Parse(results.BoundVariables["order"]); if (exp != null) { dmC.DisplayManager.SearchManager.LoadData(exp, order); dmC.DisplayManager.Position = 0; } } } } catch (Exception ex) { ExceptionProcess.ProcessWithNotify(ex); } } }