public GridWebServiceSelectResponse SelectMethod(GridWebServiceSelectRequest request) { GridWebServiceSelectResponse response = new GridWebServiceSelectResponse(); try { request.CustomParameter = "进口_备案"; WindowTabInfo tabInfo = ADInfoBll.Instance.GetWindowTabInfo(request.CustomParameter); if (tabInfo != null) { ISearchManager sm = Feng.Windows.Forms.ArchiveFormFactory.GenerateSearchManager(tabInfo, null); IList <ISearchExpression> searchExps = new List <ISearchExpression>(); IList <ISearchOrder> searchOrders = new List <ISearchOrder>(); if (!string.IsNullOrEmpty(request.Filter)) { searchExps.Add(SearchExpression.Parse(request.Filter)); } if (!string.IsNullOrEmpty(request.SortField)) { searchOrders.Add(request.SortOrder == "ASC" ? SearchOrder.Asc(request.SortField) : SearchOrder.Desc(request.SortField)); } sm.FirstResult = request.CurrentPageIndex * request.PageSize; sm.MaxResult = request.PageSize; List <TestData> arMessages = new List <TestData>(); object ret = sm.FindData(searchExps, searchOrders); System.Data.DataTable dt = ret as System.Data.DataTable; if (dt == null) { IEnumerable data = ret as IEnumerable; foreach (object obj in data) { arMessages.Add(new TestData(EntityHelper.GetPropertyValue(obj, "产地").ToString())); } } else { foreach (System.Data.DataRow row in dt.Rows) { List <object> msg = new List <object>(); foreach (string oColumn in request.Columns) { msg.Add(row[oColumn]); } //arMessages.Add(msg); } } response.RecordCount = sm.FindDataCount(searchExps); response.Items = arMessages; } else { throw new ArgumentException("Invalide tabName"); } } catch (Exception ex) { throw new ArgumentException(ex.Message); } return(response); }
public override SoaDataGridSelectResponse Select(SoaDataGridSelectRequest request) { SoaDataGridSelectResponse response = new SoaDataGridSelectResponse(); if (request.Tag == null || string.IsNullOrEmpty(request.Tag.ToString())) { return(response); } try { //WindowInfo windowInfo = ADInfoBll.Instance.GetWindowInfo(request.Tag.ToString()); //IList<WindowTabInfo> tabInfos = null; //if (windowInfo != null) //{ // tabInfos = ADInfoBll.Instance.GetWindowTabInfo(windowInfo.Id); //} Dictionary <string, string> dict = Helper.StringToDictionary(request.Tag.ToString()); if (!dict.ContainsKey("winTab") || string.IsNullOrEmpty(dict["winTab"])) { return(response); } WindowTabInfo tabInfo = ADInfoBll.Instance.GetWindowTabInfo(dict["winTab"]); if (tabInfo != null) { ISearchManager sm = Feng.Windows.Forms.ArchiveFormFactory.GenerateSearchManager(tabInfo, null); Feng.Grid.BoundGridExtention.CreateSearchManagerEagerFetchs(sm, tabInfo.GridName); IList <ISearchExpression> searchExps = new List <ISearchExpression>(); if (dict.ContainsKey("se") && !string.IsNullOrEmpty(dict["se"])) { string exp = dict["se"]; //exp = HttpUtility.UrlDecode(exp, System.Text.Encoding.GetEncoding("gb2312")); //exp = HttpContext.Current.Server.UrlDecode(exp); searchExps.Add(SearchExpression.Parse(exp)); } //if (request.Filters != null) //{ // //searchs.Add(SearchExpression.Parse(request.Tag.ToString())); // foreach (SoaDataGridDataCondition i in request.Filters) // { // switch (i.Operand) // { // case SoaDataGridDataConditionOperand.Contains: // searchExps.Add(SearchExpression.Like(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.Equals: // searchExps.Add(SearchExpression.Eq(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.GreaterThan: // searchExps.Add(SearchExpression.Gt(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.GreaterThanOrEqual: // searchExps.Add(SearchExpression.Ge(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.In: // searchExps.Add(SearchExpression.InG(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.LessThan: // searchExps.Add(SearchExpression.Lt(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.LessThanOrEqual: // searchExps.Add(SearchExpression.Le(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.NotEqualTo: // searchExps.Add(SearchExpression.NotEq(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.NotIn: // searchExps.Add(SearchExpression.NotInG(i.DataFieldName, i.DataFieldValue)); // break; // case SoaDataGridDataConditionOperand.StartsWith: // searchExps.Add(SearchExpression.Like(i.DataFieldName, i.DataFieldValue)); // break; // } // } //} IList <ISearchOrder> searchOrders = new List <ISearchOrder>(); if (request.Sortings != null) { foreach (SoaDataGridSorting i in request.Sortings) { searchOrders.Add(i.Direction == SoaSortDirection.Ascending ? SearchOrder.Asc(i.Column.Name) : SearchOrder.Desc(i.Column.Name)); } } sm.FirstResult = request.Offset; sm.MaxResult = request.Count; List <List <object> > arMessages; object ret = sm.FindData(searchExps, searchOrders); System.Data.DataTable dt = ret as System.Data.DataTable; if (dt == null) { arMessages = GenerateData(ret as IEnumerable, tabInfo.GridName, request.Columns); } else { arMessages = GenerateData(dt.Rows, tabInfo.GridName, request.Columns); } //IList<Dictionary<string, object>> values = null; // //using (DataProcess dp = new DataProcess()) //{ // if (dt == null) // { // // should be IEnumerable because IList<T> not support IList // IEnumerable data = ret as IEnumerable; // values = dp.Process(data, tabInfo.GridName); // } // else // { // values = dp.Process(dt.Rows, tabInfo.GridName); // } //} //foreach (Dictionary<string, object> obj in values) //{ // List<object> msg = new List<object>(); // foreach (SoaDataGridColumn oColumn in request.Columns) // { // if (!obj.ContainsKey(oColumn.Name)) // { // msg.Add(null); // } // else // { // msg.Add(obj[oColumn.Name]); // } // } // arMessages.Add(msg); //} response.Data = arMessages; if (sm.EnablePage) { response.ItemCount = sm.FindDataCount(searchExps); } else { response.ItemCount = arMessages.Count; } } else { throw new ArgumentException("Invalide tabName of " + dict["winTab"]); } } catch (Exception) { #if DEBUG throw; #endif } return(response); }