コード例 #1
0
        protected override FetchResult <MessageScheduleVM> _fetch(int?Skip, int?Count, NgControllerInstruct[] filters)
        {
            using (var l = new MessagesModuleLogic()) {
                IQueryable <tblMessageSchedule> baseQuery = null;

                //Special instructions filtration.
                //this SHOULD be incapsulated sometime.
                //Special instructions is query filters that not relies on main enitity POCO parametrs
                //such as tblMessageSchedule in this case, and we need special logick to handle it,
                var specialInstructions = filters == null ? null : filters.Where(x => x.isSpecial);
                NgControllerInstruct filter;
                if (specialInstructions != null &&
                    (filter = specialInstructions.FirstOrDefault(x => x.key == "TemplateName")) != null)
                {
                    baseQuery = l.GetFilteredQueryable <tblTemplate>
                                    (new[] {
                        new NgControllerInstruct {
                            key = "Name", op = filter.op, val = filter.val
                        }
                    }).SelectMany(x => x.tblMessageSchedules);
                }

                var query = l.GetFilteredQueryable(filters, baseQuery);
                int count = query.Count();
                query = query.OrderByDescending(x => x.ScheduleDate);
                if (Skip != null)
                {
                    query = query.Skip(Skip.Value);
                }
                if (Count != null)
                {
                    query = query.Take(Count.Value);
                }
                var queryResult = query.ToList().Select(x => PocoConstructor.MakeFromObj(x, MessageScheduleVM.tblMessageSchedulePR));

                return(FetchResult <MessageScheduleVM> .Succes(queryResult, count));
            }
        }
コード例 #2
0
        protected override FetchResult <BatchReportVM> _fetch(int?Skip, int?Count, NgControllerInstruct[] filters)
        {
            using (var l = new MessagesModuleLogic()) {
                var query = l.GetFilteredQueryable <tblMessageBatch>(filters);
                int count = query.Count();
                query = query.OrderByDescending(x => x.FinishedOn).ThenByDescending(x => x.CreatedOn);
                if (Skip != null)
                {
                    query = query.Skip(Skip.Value);
                }
                if (Count != null)
                {
                    query = query.Take(Count.Value);
                }
                var queryResult = query.ToList().Select(x => PocoConstructor.MakeFromObj(x, BatchReportVM.tblMessageBatchPR));

                return(FetchResult <BatchReportVM> .Succes(queryResult, count));
            }
        }
コード例 #3
0
        /// <summary>
        /// (!) Here we check period including start and including end!
        /// </summary>
        IQueryable <tblMessageSchedule> GetSchedsForDayPeriod(DateTime start, DateTime end, IQueryable <tblMessageSchedule> income)
        {
            int DayOfWeekNow = (int)start.DayOfWeek;

            var scheds =
                Logic.GetFilteredQueryable <tblMessageSchedule>()
                .Where(x => x.IsActive && (x.InArchive == null || !x.InArchive.Value))
                .Where(x =>
                       //CHECK ACTUALITY... x.ScheduleDate >= DateTime.Now - x.Actuality
                       //U WRONG, NOT HERE
                       //&&
                       (
                           (x.RepeatMode == RepeatModes.repeatMode_none &&
                            x.ScheduleDate >= start && x.ScheduleDate <= end
                           )
                           ||
                           (DbFunctions.CreateTime(x.ScheduleDate.Value.Hour, x.ScheduleDate.Value.Minute, x.ScheduleDate.Value.Second) >= start.TimeOfDay &&
                            DbFunctions.CreateTime(x.ScheduleDate.Value.Hour, x.ScheduleDate.Value.Minute, x.ScheduleDate.Value.Second) <= end.TimeOfDay &&
                            (x.RepeatMode == RepeatModes.repeatMode_day ||
                             (x.RepeatMode == RepeatModes.repeatMode_week &&
                              DbFunctions.DiffDays(firstSunday, x.ScheduleDate) % 7 == DayOfWeekNow
                             ) ||
                             (x.RepeatMode == RepeatModes.repeatMode_month &&
                              x.ScheduleDate.Value.Day == start.Day
                             ) ||
                             (x.RepeatMode == RepeatModes.repeatMode_year &&
                              x.ScheduleDate.Value.Month == start.Month &&
                              x.ScheduleDate.Value.Day == start.Day
                             )
                            )
                           )
                       )
                       );

            income = income == null ? scheds : income.Concat(scheds);
            return(income);
        }
コード例 #4
0
 public IQueryable <IEmailServiceProvider> GetActiveEmailProviders()
 {
     return(Logic.GetFilteredQueryable <tblEmailSenderDataProvider>()
            .Where(x => x.IsActive));
 }