public void GetEntryList_by_expression_qulifier_fieldIds_haspage_hascount_noorder_success() { ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd); try { TotalMatch total = new TotalMatch(); ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context); var retlist = proxy.GetEntryList( m => m.CharacterField.Contains("%你好%"), 0, 5, total, null, m => m.CharacterField, m => m.RequestID ); Assert.AreEqual(5, retlist.Count); Assert.AreEqual(11, total.Value); foreach (var entry in retlist) { Assert.AreEqual(true, entry.CharacterField.Contains("你好")); } Assert.AreEqual(4, Convert.ToInt32(retlist.Max(m => m.RequestID)) - Convert.ToInt32(retlist.Min(m => m.RequestID))); } catch (Exception ex) { Assert.AreEqual(null, ex); } finally { context.Dispose(); } }
public static IList <TModel> GetEntryList <TModel>(this ARProxy <TModel> proxy, string qualification, uint StartIndex, uint?RetrieveCount, TotalMatch totalMatch, List <ARSortInfo> sortInfo, params Expression <Func <TModel, object> >[] propertiesTobeUp) where TModel : ARBaseForm { if (propertiesTobeUp == null || propertiesTobeUp.Length == 0) { return(null); } ITypeMetaProvider <TModel> metaProvider = new ExpressionTypeMetaProvider <TModel>(propertiesTobeUp); ModelMeteData <TModel> MetaData = new ModelMeteData <TModel>(); MetaData.FormName = metaProvider.GetFormNameFromModelType(); var props = metaProvider.GetPropertyInfoes(BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance, null); MetaData.Properties = new List <PropertyAndField <TModel> >(); foreach (var p in props) { if ((p.AccessLevel & ModelBinderAccessLevel.OnlyBind) == ModelBinderAccessLevel.OnlyBind) { MetaData.Properties.Add(p); } } return(proxy.GetEntryList(StartIndex, qualification, MetaData, RetrieveCount, totalMatch, sortInfo)); }
public void ARProxy_GetEntryList_qulifier_fieldIds_nopage_hascount_hasorder_success() { ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd); try { TotalMatch total = new TotalMatch(); List <UInt32> fieldIds = new List <UInt32>(); fieldIds.Add(TestCharacterFieldId); fieldIds.Add(TestIntFieldId); fieldIds.Add(1u); List <ARSortInfo> sortInfo = new List <ARSortInfo>(); sortInfo.Add(new ARSortInfo { FieldId = TestCharacterFieldId, Order = SortOrder.SORT_DESCENDING }); ARProxy <NRemedy_Test_Regular_Form> proxy = new ARProxy <NRemedy_Test_Regular_Form>(context); var retlist = proxy.GetEntryList( "'Character Field' LIKE \"%你好%\"", fieldIds, 0, null, total, sortInfo ); Assert.AreEqual(11, retlist.Count); Assert.AreEqual(11, total.Value); foreach (var entry in retlist) { Assert.AreEqual(true, entry.CharacterField.Contains("你好")); } Assert.AreEqual(10, Convert.ToInt32(retlist.Max(m => m.RequestID)) - Convert.ToInt32(retlist.Min(m => m.RequestID))); Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[0].CharacterField); Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[1].CharacterField); } catch (Exception ex) { Assert.AreEqual(null, ex); } finally { context.Dispose(); } }
public static IList <TModel> GetEntryList <TModel>(this ARProxy <TModel> proxy, Expression <Func <TModel, bool> > expression, uint StartIndex, uint?RetrieveCount, TotalMatch totalMatch, List <ARSortInfo> sortInfo, params Expression <Func <TModel, object> >[] propertiesTobeUp) where TModel : ARBaseForm { if (expression == null) { throw new ArgumentNullException("expression must not null. If want to delete all entries, try to use m => true"); } ConditionExpressionVisitor visitor = new ConditionExpressionVisitor(); var expEvaled = Evaluator.PartialEval(expression); ConditionResult tr = visitor.Translate(expEvaled); string qu = tr.Qulification == null ? null : tr.Qulification.ToString(); return(GetEntryList(proxy, qu, StartIndex, RetrieveCount, totalMatch, sortInfo, propertiesTobeUp)); }
public void GetEntryList_by_expression_qulifier_fieldIds_haspage_hascount_noorder_success() { ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd); try { TotalMatch total = new TotalMatch(); ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context); var retlist = proxy.GetEntryList( m => m.CharacterField.Contains("%你好%"), 0, 5, total, null, m => m.CharacterField, m => m.RequestID ); Assert.AreEqual(5, retlist.Count); Assert.AreEqual(11, total.Value); foreach (var entry in retlist) { Assert.AreEqual(true, entry.CharacterField.Contains("你好")); } Assert.AreEqual(4, Convert.ToInt32(retlist.Max(m => m.RequestID)) - Convert.ToInt32(retlist.Min(m => m.RequestID))); } catch (Exception ex) { Assert.AreEqual(null, ex); } finally { context.Dispose(); } }
public void ARProxy_GetEntryList_qulifier_fieldIds_nopage_hascount_hasorder_success() { ARLoginContext context = new ARLoginContext(TestServer, TestAdmin, TestAdminPwd); try { TotalMatch total = new TotalMatch(); List<UInt32> fieldIds = new List<UInt32>(); fieldIds.Add(TestCharacterFieldId); fieldIds.Add(TestIntFieldId); fieldIds.Add(1u); List<ARSortInfo> sortInfo = new List<ARSortInfo>(); sortInfo.Add(new ARSortInfo { FieldId = TestCharacterFieldId, Order = SortOrder.SORT_DESCENDING }); ARProxy<NRemedy_Test_Regular_Form> proxy = new ARProxy<NRemedy_Test_Regular_Form>(context); var retlist = proxy.GetEntryList( "'Character Field' LIKE \"%你好%\"", fieldIds, 0, null, total, sortInfo ); Assert.AreEqual(11, retlist.Count); Assert.AreEqual(11, total.Value); foreach (var entry in retlist) { Assert.AreEqual(true, entry.CharacterField.Contains("你好")); } Assert.AreEqual(10, Convert.ToInt32(retlist.Max(m => m.RequestID)) - Convert.ToInt32(retlist.Min(m => m.RequestID))); Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[0].CharacterField); Assert.AreEqual(TestCharacterFieldValueChinese + "Set Something", retlist[1].CharacterField); } catch (Exception ex) { Assert.AreEqual(null, ex); } finally { context.Dispose(); } }