Exemple #1
0
        private IQueryable <TaskSearch> GetBaseResults(CMSDataContext db, TaskSearchInfo.OptionInfo opt)
        {
            var u     = db.CurrentUser;
            var roles = u.UserRoles.Select(uu => uu.Role.RoleName.ToLower()).ToArray();
            var managePrivateContacts = HttpContextFactory.Current.User.IsInRole("ManagePrivateContacts");
            var manageTasks           = HttpContextFactory.Current.User.IsInRole("ManageTasks") && !opt.MyTasksOnly;
            var uid = Util.UserPeopleId;
            var q   = from t in db.ViewTaskSearches
                      where (t.LimitToRole ?? "") == "" || roles.Contains(t.LimitToRole) || managePrivateContacts
                      where manageTasks || t.OrginatorId == uid || t.OwnerId == uid || t.CoOwnerId == uid
                      where t.Archive == opt.Archived
                      select t;

            if (opt.Status == 99)
            {
                q = from t in q
                    where new[] { TaskStatusCode.Active, TaskStatusCode.Pending }.Contains(t.StatusId ?? 0)
                select t;
            }
            else if (opt.Status > 0)
            {
                q = from t in q
                    where t.StatusId == opt.Status
                    select t;
            }

            if (opt.ExcludeNewPerson)
            {
                q = from t in q
                    where !t.Description.StartsWith("New Person")
                    select t;
            }

            if (opt.MyTasksOnly)
            {
                q = from t in q
                    select t;
            }

            if (opt.Lookback.HasValue)
            {
                var ed = opt.EndDt;
                if (!ed.HasValue)
                {
                    ed = DateTime.Today.AddDays(1);
                }

                q = from t in q
                    where t.Created >= ed.Value.AddDays(-opt.Lookback.Value)
                    select t;
            }
            if (opt.EndDt.HasValue)
            {
                q = from t in q
                    where t.Created <= opt.EndDt
                    select t;
            }

            return(q);
        }
Exemple #2
0
        private static IQueryable <TaskSearch> GetBaseResults(CMSDataContext db, TaskSearchInfo.OptionInfo opt)
        {
            var u     = db.CurrentUser;
            var roles = u.UserRoles.Select(uu => uu.Role.RoleName.ToLower()).ToArray();
            var managePrivateContacts = HttpContext.Current.User.IsInRole("ManagePrivateContacts");
            var manageTasks           = HttpContext.Current.User.IsInRole("ManageTasks") && !opt.MyTasksOnly;
            var uid = Util.UserPeopleId;
            var q   = from t in db.ViewTaskSearches
                      where (t.LimitToRole ?? "") == "" || roles.Contains(t.LimitToRole) || managePrivateContacts
                      where manageTasks || t.OrginatorId == uid || t.OwnerId == uid || t.CoOwnerId == uid
                      where t.Archive == opt.Archived
                      select t;

            if (opt.Status == 99)
            {
                q = from t in q
                    where new[] { TaskStatusCode.Active, TaskStatusCode.Pending }
            }