/// <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; //} }
/// <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> /// 根据可读字符串得到查询顺序 /// 例如 Title, Name Desc, Help Asc. Asc 默认 /// </summary> /// <param name="searchOrders"></param> /// <returns></returns> public static IList <ISearchOrder> Parse(string searchOrders) { if (string.IsNullOrEmpty(searchOrders)) { return(null); } IList <ISearchOrder> ret = new List <ISearchOrder>(); string[] ss = searchOrders.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string s in ss) { string[] s2 = s.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (s2.Length == 1) { ret.Add(SearchOrder.Asc(s2[0].Trim())); } else if (s2.Length == 2) { if (s2[1].ToUpper() == "DESC") { ret.Add(SearchOrder.Desc(s2[0].Trim())); } else if (s2[1].ToUpper() == "ASC") { ret.Add(SearchOrder.Asc(s2[0].Trim())); } else { throw new ArgumentException("SearchOrder of " + searchOrders + " format is invalid!"); } } else { throw new ArgumentException("SearchOrder of " + searchOrders + " format is invalid!"); } } return(ret); }
/// <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> /// 按照自定义规则按照地址导航程序到某个界面 /// 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); } } }