void selectSemesterAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e) { ObjectSpace objectSpace = Application.CreateObjectSpace(); ListView lv = ((ListView)((WindowController)sender).Window.View); Semester semester = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester; GroupOperator classroomsOp = new GroupOperator(CriteriaOperator.Parse("1=0")); ContainsOperator biOperator; string strParse = ""; if (semester != null) { foreach (StudentClass studentClass in View.SelectedObjects) { Data.CreateStudentClassTimetableData(objectSpace, studentClass.ClassCode, semester.SemesterName); biOperator = new ContainsOperator("StudentClasses", new BinaryOperator("ClassCode", studentClass.ClassCode)); classroomsOp = new GroupOperator(GroupOperatorType.Or, classroomsOp, biOperator); strParse += (strParse == "" ? string.Format("ClassCode='{0}'", studentClass.ClassCode) : string.Format(" or ClassCode='{0}'", studentClass.ClassCode)); } ReportData reportData = objectSpace.FindObject<ReportData>( new BinaryOperator("Name", "Lịch lớp biên chế")); ReportServiceController rsc = ((WindowController)sender).Frame.GetController<ReportServiceController>(); rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse)); //classroomsOp); } }
public XPCollection <CustomFieldDataString> GetSelecteCustomFieldAllDataItems(Session session, Guid objectCustomFieldId) { try { ObjectCustomField ocf = session.GetObjectByKey <ObjectCustomField>(objectCustomFieldId); if (ocf == null) { throw new Exception("Input key is not exist in ObjectCustomField"); } if (ocf.ObjectTypeCustomFieldId == null || ocf.ObjectTypeCustomFieldId.CustomFieldId == null || ocf.ObjectTypeCustomFieldId.CustomFieldId.CustomFieldTypeId == null) { throw new Exception("ObjectCustomField's configuration is wrong"); } if (!ocf.ObjectTypeCustomFieldId.CustomFieldId.CustomFieldTypeId.Code.Equals("MULTI_CHOICE_LIST")) { throw new Exception("ObjectCustomField is not single selection list type"); } CriteriaOperator criteria = new ContainsOperator("ObjectCustomFieldDatas", new BinaryOperator("ObjectCustomFieldId", ocf)); XPCollection <CustomFieldDataString> rs = new XPCollection <CustomFieldDataString>(session, criteria); return(rs); } catch (Exception e) { throw e; } }
void selectSemesterAcception_Accepting(object sender, DialogControllerAcceptingEventArgs e) { ObjectSpace objectSpace = Application.CreateObjectSpace(); ListView lv = ((ListView)((WindowController)sender).Window.View); Semester semester = lv.SelectedObjects.Count == 0 ? null : lv.SelectedObjects[0] as Semester; GroupOperator classroomsOp = new GroupOperator(CriteriaOperator.Parse("1=0")); ContainsOperator biOperator; string strParse = ""; if (semester != null) { foreach (Student student in View.SelectedObjects) { Data.CreateStudentTimetableData(objectSpace, student.StudentCode, semester.SemesterName); biOperator = new ContainsOperator("Students", new BinaryOperator("StudentCode", student.StudentCode)); classroomsOp = new GroupOperator(GroupOperatorType.Or, classroomsOp, biOperator); strParse += (strParse == "" ? string.Format("StudentCode='{0}'", student.StudentCode) : string.Format(" or StudentCode='{0}'", student.StudentCode)); } ReportData reportData = objectSpace.FindObject <ReportData>( new BinaryOperator("Name", "Lịch sinh viên")); ReportServiceController rsc = ((WindowController)sender).Frame.GetController <ReportServiceController>(); rsc.ShowPreview((IReportData)reportData, CriteriaOperator.Parse(strParse)); //classroomsOp); } }
public static RouteStationConfiguration GetConfigurationFor(RouteStation station, Part part) { ICollection <RouteStationConfiguration> configurations; BinaryOperator op1 = new BinaryOperator("Part", part); BinaryOperator op2 = new BinaryOperator("Station", station); ContainsOperator containsOperator = new ContainsOperator("Config.ConfigurationParts", op1); GroupOperator groupOperator = new GroupOperator(op2, containsOperator); configurations = Repository .GetList <RouteStationConfiguration>(part.Session) .ByCriteria(groupOperator); if (configurations.Count == 0) { return(null); } foreach (RouteStationConfiguration config in configurations) { if (config != null) { return(config); } } return(null); }
/// <summary> /// Map if contains the value of http header specified. /// </summary> /// <returns>The http header.</returns> /// <param name="source">Source.</param> /// <param name="httpHeaderName">Http header name.</param> public static ILogicOperator ContainsHttpHeader(this IOperand source, string httpHeaderName) { var op = new ContainsOperator(source, new HttpHeaderOperand(httpHeaderName)); source.Operator = op; return(op); }
/// <summary> /// Map if contains the value. /// </summary> /// <returns>The value.</returns> /// <param name="source">Source.</param> /// <param name="value">Value.</param> public static ILogicOperator ContainsValue(this IOperand source, string value) { var op = new ContainsOperator(source, new FixedValueOperand(value)); source.Operator = op; return(op); }
public void ExtractContainsNullOperator() { var nullOperator = new NullOperator(); var containsOperator = new ContainsOperator("", nullOperator); CriteriaOperatorExtractor binaryOperatorExtractor = GetBinaryOperatorExtractor(containsOperator); Assert.AreEqual(nullOperator, binaryOperatorExtractor.NullOperators[0]); }
public override IQueryable <RoleModelDifferenceObject> GetActiveModelDifferences(string applicationName, string name, DeviceCategory deviceCategory = DeviceCategory.All) { var userWithRoles = SecuritySystem.CurrentUser as IUserWithRoles; var collection = GetRoles(userWithRoles); if (collection != null) { var roleType = ((IRoleTypeProvider)SecuritySystem.Instance).RoleType; var roleTypeInfo = XafTypesInfo.Instance.PersistentTypes.First(info => info.Type == roleType); var criteria = new ContainsOperator("Roles", new InOperator(roleTypeInfo.KeyMember.Name, collection.ToList())); var roleAspectObjects = base.GetActiveModelDifferences(applicationName, name, deviceCategory).ToArray(); return(roleAspectObjects.Where(aspectObject => aspectObject.Fit(criteria.ToString())).AsQueryable()); } return(base.GetActiveModelDifferences(applicationName, name, deviceCategory).OfType <RoleModelDifferenceObject>().AsQueryable()); }
public XPCollection <NAS.DAL.CMS.ObjectDocument.Object> FindCMSObjectsOfBuiltInCustomField( Session session, Guid objectTypeCustomFieldId, List <Guid> refIds) { try { if (refIds == null) { return(null); } XPCollection <NAS.DAL.CMS.ObjectDocument.Object> objectList = null; //Get object type custom field ObjectTypeCustomField objectTypeCustomField = session.GetObjectByKey <ObjectTypeCustomField>(objectTypeCustomFieldId); if (objectTypeCustomField == null) { return(null); } if (objectTypeCustomField.ObjectCustomFields == null || objectTypeCustomField.ObjectCustomFields.Count == 0) { return(null); } CriteriaOperator criteria = new ContainsOperator("ObjectCustomFieldDatas", new InOperator("CustomFieldDataId.<PredefinitionData>RefId", refIds)); XPCollection <ObjectCustomField> objectCustomFieldList = objectTypeCustomField.ObjectCustomFields; objectCustomFieldList.Criteria = criteria; objectList = new XPCollection <DAL.CMS.ObjectDocument.Object>(session, objectCustomFieldList.Select(r => r.ObjectId)); //(XPCollection<NAS.DAL.CMS.ObjectDocument.Object>) // objectCustomFieldList.Select(r => r.ObjectId); return(objectList); } catch (Exception) { throw; } }
public void ExtractNestedGroupOperator() { BinaryOperator binaryOperator2; CriteriaOperator nestedGroupOperator; BinaryOperator binaryOperator1 = getGroupOperator(out binaryOperator2, out nestedGroupOperator); var groupOperator = new GroupOperator(nestedGroupOperator, binaryOperator1, binaryOperator2); CriteriaOperator containsOperator = new ContainsOperator("", groupOperator); var extractor = new CriteriaOperatorExtractor(); extractor.Extract(containsOperator); Assert.AreEqual(4, extractor.BinaryOperators.Count); Assert.AreEqual(binaryOperator1, extractor.BinaryOperators[0]); Assert.AreEqual(binaryOperator2, extractor.BinaryOperators[1]); Assert.AreEqual(binaryOperator1, extractor.BinaryOperators[2]); Assert.AreEqual(binaryOperator2, extractor.BinaryOperators[3]); }
public override IQueryable <RoleModelDifferenceObject> GetActiveModelDifferences(string applicationName, string name) { var userWithRoles = SecuritySystem.CurrentUser as IUserWithRoles; if (userWithRoles != null) { IEnumerable <object> collection = userWithRoles.Roles.Cast <XPBaseObject>().Select(role => role.ClassInfo.KeyProperty.GetValue(role)); Type roleType = ((ISecurityComplex)SecuritySystem.Instance).RoleType; ITypeInfo roleTypeInfo = XafTypesInfo.Instance.PersistentTypes.Where(info => info.Type == roleType).Single(); var criteria = new ContainsOperator("Roles", new InOperator(roleTypeInfo.KeyMember.Name, collection.ToList())); var roleAspectObjects = base.GetActiveModelDifferences(applicationName, name).ToList(); return(roleAspectObjects.OfType <RoleModelDifferenceObject>().Where(aspectObject => aspectObject.Fit(criteria.ToString())).AsQueryable()); } return(base.GetActiveModelDifferences(applicationName, name).OfType <RoleModelDifferenceObject>().AsQueryable()); }
public void ShouldContains() { // Given var filter = new ContainsOperator(EntityType, StringField, "23"); var satisfyEntity = new FilterTestEntity { StringField = "1234" }; var noSatisfyEntity = new FilterTestEntity { StringField = "5678" }; // When var isSatisfy = filter.IsSatisfiedBy(satisfyEntity); var isNoSatisfy = filter.IsSatisfiedBy(noSatisfyEntity); // Then Assert.IsTrue(isSatisfy); Assert.IsFalse(isNoSatisfy); }
public void CreateExpressionTest1() { // Arrange var parameterExpression = Expression.Parameter(typeof(Employee), "sample"); var expressionProperty = Expression.Property(parameterExpression, nameof(Employee.FirstName)); var containsOperator = new ContainsOperator(); Expression leftExpression = containsOperator.CreateExpression(expressionProperty, Expression.Constant("xxx")); Expression rightExpression = containsOperator.CreateExpression(expressionProperty, Expression.Constant("yyy")); Expression expectedExpression = Expression.Or(leftExpression, rightExpression); var _operator = new OrOperator(); // Act Expression resultExpression = _operator.CreateExpression(leftExpression, rightExpression); // Assert Assert.AreEqual(expectedExpression.ToString(), resultExpression.ToString(), "Expression not correct"); }
private void RefreshCustomer() { if (customerDataSource == null) { return; } // Process the situation when the Party is not specified (see the Scenario 3 above) if (Agent == null) { // Show only Global Collection when the Party is not specified //fAvailableBookingOrders.Criteria = CriteriaOperator.Parse("1=1"); } else { // Leave only the current Party's Collection in the fAvailableSampleCollection collection customerDataSource.Criteria = ContainsOperator.Parse("Agent = ?", Agent); } // Set null for the Collection property to allow an end-user //to set a new value from the refreshed data source Customer = null; }
public void CreateExpressionTest1() { // Arrange Expression parameterExpression = Expression.Parameter(typeof(Employee), "sample"); Expression expressionProperty = Expression.Property(parameterExpression, nameof(Employee.FirstName)); Expression expressionConstant = Expression.Constant("xxx"); MethodInfo methodInfo = expressionProperty.Type.GetMethod("Contains", new[] { typeof(string) }); Expression expectedExpression = Expression.Call(expressionProperty, methodInfo ?? throw new InvalidOperationException(), expressionConstant); var _operator = new ContainsOperator(); // Act Expression resultExpression = _operator.CreateExpression(expressionProperty, expressionConstant); // Assert Assert.AreEqual(expectedExpression.ToString(), resultExpression.ToString(), "Expression not correct"); }
public void RefreshInstrument() { if (fAvailableInstruments == null) { return; } // Process the situation when the Party is not specified (see the Scenario 3 above) if (CashBank == null) { // Show only Global Collection when the Party is not specified //fAvailableBookingOrders.Criteria = CriteriaOperator.Parse("1=1"); } else { // Leave only the current Party's Collection in the fAvailableSampleCollection collection //fAvailableBookingOrders.Criteria = new BinaryOperator("Customer", Customer); fAvailableInstruments.Criteria = ContainsOperator.Parse("[CashBanks][[Oid] = ?]", CashBank.Oid); } // Set null for the Collection property to allow an end-user //to set a new value from the refreshed data source Instrument = null; }
private void btnFiterStandard_Click(object sender, System.EventArgs e) { CriteriaOperator criteria = new ContainsOperator("Orders", new BinaryOperator("Employee.LastName", "Buchanan")); SetFilter(criteria); }