Exemplo n.º 1
0
        /// <summary>
        /// Gets the pending notification list.
        /// </summary>
        /// <returns></returns>
        public static List <vNotification> GetPendingNotificationList()
        {
            INotificationService service = (INotificationService)EntityFactory.GetEntityServiceByName(
                vNotification.EntityName, "");

            FilterExpression filterEmail = new FilterExpression();

            filterEmail.AddFilter(new Filter(vNotification.ColumnNames.EmailNotificationStatusID, (int)EntityEnums.NotificationStatusEnum.Pending));
            filterEmail.AddFilter(new Filter(vNotification.ColumnNames.IsEmail, true));
            filterEmail.AddFilter(new Filter(vNotification.ColumnNames.ReceiverUserEmail, null, FilterOperatorEnum.NotIsNull));

            FilterExpression filterSMS = new FilterExpression();

            filterSMS.AddFilter(new Filter(vNotification.ColumnNames.SMSNotificationStatusID, (int)EntityEnums.NotificationStatusEnum.Pending));
            filterSMS.AddFilter(new Filter(vNotification.ColumnNames.IsSMS, true));
            filterSMS.AddFilter(new Filter(vNotification.ColumnNames.ReceiverUserPhoneNumber, null, FilterOperatorEnum.NotIsNull));

            FilterExpression filter = new FilterExpression();

            filter.AddFilterExpression(filterEmail);
            filter.AddFilterExpression(filterSMS);
            filter.LogicalOperator = FilterLogicalOperatorEnum.OR;

            SortExpression sort = new SortExpression(vNotification.ColumnNames.InsertDate, SortDirectionEnum.ASC);

            int numberOfNotifies = 100;
            List <vNotification> notificationList = (List <vNotification>)
                                                    service.GetByFilter(new GetByFilterParameters(filter, sort, 0, numberOfNotifies, null, GetSourceTypeEnum.View));

            return(notificationList);
        }
        public void GetFilterStringTest4()
        {
            FilterExpression target = new FilterExpression();

            target.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C1"));
            target.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C2"));
            target.LogicalOperator = FilterLogicalOperatorEnum.OR;
            FilterExpression filterExp2 = new FilterExpression();

            filterExp2.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C3"));
            filterExp2.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C4"));
            target.AddFilterExpression(filterExp2);
            Assert.AreEqual(target.FiltersList.Count, 3);
            List <object> filterValues = new List <object>();
            string        actual       = target.GetFilterString(filterValues);
            string        expected     = "(" + GetSimpleFilterString(vTestCaseTester.ColumnNames.FieldString, "=", Filter.ParameterPrefix + "0") +
                                         " OR " + GetSimpleFilterString(vTestCaseTester.ColumnNames.FieldString, "=", Filter.ParameterPrefix + "1") + "" +
                                         " OR (" + GetSimpleFilterString(vTestCaseTester.ColumnNames.FieldString, "=", Filter.ParameterPrefix + "2") + "" +
                                         " AND " + GetSimpleFilterString(vTestCaseTester.ColumnNames.FieldString, "=", Filter.ParameterPrefix + "3") + ")" +
                                         ")";

            Assert.AreEqual(expected, actual);
            Assert.AreEqual(filterValues.Count, 4);
            Assert.AreEqual(filterValues[0], "C1");
            Assert.AreEqual(filterValues[1], "C2");
            Assert.AreEqual(filterValues[2], "C3");
            Assert.AreEqual(filterValues[3], "C4");
        }
        public void AddFilterExpressionTest()
        {
            FilterExpression target    = new FilterExpression();
            FilterExpression filterExp = new FilterExpression();

            filterExp.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C'ode"));
            target.AddFilterExpression(filterExp);
            Assert.AreEqual(target.FiltersList.Count, 1);
            var enumerator = target.FiltersList.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual(enumerator.Current, filterExp);
        }
        public void CloneTest()
        {
            FilterExpression target = new FilterExpression();

            target.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C1"));
            target.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C2"));
            FilterExpression f2 = new FilterExpression();

            f2.AddFilter(new Filter(vTestCaseTester.ColumnNames.FieldString, "C3"));
            target.AddFilterExpression(f2);
            FilterExpression actual;

            actual = (FilterExpression)target.Clone();
            Assert.AreEqual(actual.FiltersList.Count, target.FiltersList.Count);
            var enumeratorTarget = target.FiltersList.GetEnumerator();
            var enumeratorActual = actual.FiltersList.GetEnumerator();

            while (enumeratorTarget.MoveNext())
            {
                enumeratorActual.MoveNext();
                Assert.AreEqual(enumeratorTarget.Current, enumeratorActual.Current);
            }
        }