Ejemplo n.º 1
0
        public dataTableResult <ActivityList> GetIndexView(viewOptions o, string culture)
        {
            var result = new dataTableResult <DTO.ActivityList>();
            IQueryable <Activity> q = dbset.AsNoTracking();

            if (o.personID > 0 && o.attendedActivities == false)
            {
                IndexViewBase.getUnassociated(o.personID, ref q, db);
            }
            if (o.personID > 0 && o.attendedActivities == true)
            {
                IndexViewBase.getAssociated(o.personID, ref q, db);
            }

            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            result.filteredCount = q.Count();
            result.totalCount    = TotalCount();
            result.query         = q.ProjectTo <DTO.ActivityList>(map.ConfigurationProvider)
                                   .Skip(o.displayStart)
                                   .Take(o.displayLength)
                                   .AsEnumerable();
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public dataTableResult <DTO.EmployersList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.EmployersList>();
            //Get all the records
            IQueryable <Employer> q = repo.GetAllQ();

            //Search based on search-bar string
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            if (o.onlineSource == true)
            {
                IndexViewBase.filterOnlineSource(o, ref q);
            }
            //Sort the Persons based on column selection
            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            //Limit results to the display length and offset
            result.filteredCount = q.Count();
            result.totalCount    = repo.GetAllQ().Count();
            result.query         = q.ProjectTo <DTO.EmployersList>(map.ConfigurationProvider)
                                   .Skip(o.displayStart)
                                   .Take(o.displayLength)
                                   .AsEnumerable();
            return(result);
        }
Ejemplo n.º 3
0
        public dataTableResult <Email> GetIndexView(viewOptions o)
        {
            var result           = new dataTableResult <Email>();
            IQueryable <Email> q = repo.GetAllQ();

            if (o.woid > 0)
            {
                IndexViewBase.filterOnWorkorder(o, ref q);
            }
            if (o.emailID.HasValue)
            {
                IndexViewBase.filterOnID(o, ref q);
            }
            if (o.EmployerID.HasValue)
            {
                IndexViewBase.filterOnEmployer(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IEnumerable <Email> e = q.AsEnumerable();

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref e);
            result.filteredCount = e.Count();
            result.totalCount    = repo.GetAllQ().Count();
            result.query         = e.Skip(o.displayStart).Take(o.displayLength);
            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public dataTableResult <DTO.EventList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.EventList>();
            //Get all the records
            IQueryable <Event> q = GetEvents(o.personID);

            result.totalCount = q.Count();
            //Search based on search-bar string
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                q = GetEvents(o.personID)
                    .Where(p => p.notes.Contains(o.sSearch));
            }

            //Sort the Persons based on column selection
            switch (o.sortColName)
            {
            case "dateupdated": q = o.orderDescending ? q.OrderByDescending(p => p.dateupdated) : q.OrderBy(p => p.dateupdated); break;

            default: q = o.orderDescending ? q.OrderByDescending(p => p.dateupdated) : q.OrderBy(p => p.dateupdated); break;
            }

            //Limit results to the display length and offset
            result.filteredCount = q.Count();
            result.query         = q.ProjectTo <DTO.EventList>(map.ConfigurationProvider)
                                   .Skip(o.displayStart)
                                   .Take(o.displayLength)
                                   .AsEnumerable();
            return(result);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Provide combined summary of WO/WA status
        /// </summary>
        /// <param name="search">Search text criteria</param>
        /// <param name="orderDescending">Flag indicating whether results are sorted in descending order</param>
        /// <param name="displayStart">Record to start displaying (used for pagination)</param>
        /// <param name="displayLength">Number of records to display</param>
        /// <returns>WO/WA Summary table of status counts for a given day</returns>
        public dataTableResult <WOWASummary> CombinedSummary(string search,
                                                             bool orderDescending,
                                                             int displayStart,
                                                             int displayLength)
        {
            IEnumerable <WorkOrderSummary>      woResult;
            IEnumerable <WorkAssignmentSummary> waResult;
            IEnumerable <WOWASummary>           q;
            var result = new dataTableResult <WOWASummary>();

            //pulling from DB here because the joins grind it to a halt
            // TODO: investigate how to do a left join - results only appear when there are WA assigned to WO
            woResult = GetSummary(search).AsEnumerable();
            waResult = waServ.GetSummary(search).AsEnumerable();
            q        = woResult.Join(waResult,
                                     wo => new { wo.date, wo.status },
                                     wa => new { wa.date, wa.status },
                                     (wo, wa) => new
            {
                wo.date,
                wo.status,
                wo_count = wo.count,
                wa_count = wa.count
            })
                       .GroupBy(gb => gb.date)
                       .Select(g => new WOWASummary
            {
                date         = g.Key,
                weekday      = Convert.ToDateTime(g.Key).ToString("dddd"),
                pending_wo   = g.Where(c => c.status == WorkOrder.iPending).Sum(d => d.wo_count),
                pending_wa   = g.Where(c => c.status == WorkOrder.iPending).Sum(d => d.wa_count),
                active_wo    = g.Where(c => c.status == WorkOrder.iActive).Sum(d => d.wo_count),
                active_wa    = g.Where(c => c.status == WorkOrder.iActive).Sum(d => d.wa_count),
                completed_wo = g.Where(c => c.status == WorkOrder.iCompleted).Sum(d => d.wo_count),
                completed_wa = g.Where(c => c.status == WorkOrder.iCompleted).Sum(d => d.wa_count),
                cancelled_wo = g.Where(c => c.status == WorkOrder.iCancelled).Sum(d => d.wo_count),
                cancelled_wa = g.Where(c => c.status == WorkOrder.iCancelled).Sum(d => d.wa_count),
                expired_wo   = g.Where(c => c.status == WorkOrder.iExpired).Sum(d => d.wo_count),
                expired_wa   = g.Where(c => c.status == WorkOrder.iExpired).Sum(d => d.wa_count)
            });

            // Sort results on date (depending on orderDescending input parameter)
            if (orderDescending)
            {
                q = q.OrderByDescending(p => p.date);
            }
            else
            {
                q = q.OrderBy(p => p.date);
            }

            result.filteredCount = q.Count();
            result.query         = q.Skip <WOWASummary>((int)displayStart).Take((int)displayLength);
            result.totalCount    = repo.GetAllQ().Count();
            return(result);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// This method returns the view data for the Worker Signin class.
        /// </summary>
        /// <param name="o">View options from DataTables</param>
        /// <returns>dataTableResult WorkerSigninList</returns>
        public dataTableResult <DTO.WorkerSigninList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.WorkerSigninList>();
            IQueryable <WorkerSignin> q = GetAll();

            var unused = q.Count();

            if (o.date != null)
            {
                var requestedDate = o.date.Value.DateBasedOn(ClientTimeZoneInfo); // 12:00:00 AM client time
                var endOfDay      = requestedDate.AddDays(1).AddMilliseconds(-1);

                var qDates = q.Select(the => new { the.ID, the.dateforsignin }).ToList();

                var qIDs = qDates.Where(the =>
                                        the.dateforsignin.DateTimeFrom(ClientTimeZoneInfo) >= requestedDate &&
                                        the.dateforsignin.DateTimeFrom(ClientTimeZoneInfo) <= endOfDay)
                           .Select(the => the.ID);

                q = q.Where(wsi => qIDs.Contains(wsi.ID));
                var blah = q.Count();
            }

            if (o.typeofwork_grouping != null)
            {
                IndexViewBase.typeOfWork(o, ref q);
            }
            IndexViewBase.waGrouping(o, ref q, db.WorkerRequests.AsNoTracking().AsQueryable());
            if (o.dwccardnum > 0)
            {
                IndexViewBase.dwccardnum(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            result.filteredCount = q.Count();
            result.totalCount    = GetAll().Count();
            if (o.displayLength > 0)
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            return(result);
        }
Ejemplo n.º 7
0
        public dataTableResult <DTO.PersonList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.PersonList>();
            //Get all the records
            IQueryable <Person> q = GetAll();

            result.totalCount = q.Count();
            //
            //Search based on search-bar string
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }
            if (o.showWorkers == true)
            {
                IndexViewBase.getWorkers(o, ref q);
            }
            if (o.showNotWorkers == true)
            {
                IndexViewBase.getNotWorkers(o, ref q);
            }
            if (o.showExpiredWorkers == true)
            {
                IndexViewBase.getExpiredWorkers(o,
                                                WorkOrder.iExpired,
                                                ref q);
            }
            if (o.showSExWorkers == true)
            {
                IndexViewBase.getSExWorkers(o,
                                            Worker.iSanctioned,
                                            Worker.iExpelled,
                                            ref q);
            }
            if (o.showActiveWorkers == true)
            {
                IndexViewBase.GetActiveWorkers(Worker.iActive,
                                               ref q);
            }
            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);

            result.filteredCount = q.Count();
            result.totalCount    = GetAll().Count();
            result.query         = q.ProjectTo <DTO.PersonList>(map.ConfigurationProvider)
                                   .Skip(o.displayStart)
                                   .Take(o.displayLength)
                                   .AsEnumerable();
            return(result);
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <returns></returns>
        public dataTableResult <DTO.ActivitySigninList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.ActivitySigninList>();
            IQueryable <ActivitySignin> q = repo.GetAllQ();

            //
            if (o.date != null)
            {
                // good intentions marinated in panic
                q = q.Where(p =>
                            p.dateforsignin.DateBasedOn(ClientTimeZoneInfo) == o.date.Value.DateBasedOn(ClientTimeZoneInfo)
                            );
            }

            if (o.personID > 0)
            {
                IndexViewBase.GetAssociated(o.personID, ref q);
            }
            if (o.activityID != null)
            {
                q = q.Where(p => p.activityID == o.activityID);
            }
            //
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            result.filteredCount = q.Count();
            result.totalCount    = repo.GetAllQ().Count();
            if (o.displayLength > 0)
            {
                result.query = q.ProjectTo <DTO.ActivitySigninList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.ActivitySigninList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            return(result);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// This method returns the view data for the Worker Signin class.
        /// </summary>
        /// <param name="o">View options from DataTables</param>
        /// <returns>dataTableResult WorkerSigninList</returns>
        public dataTableResult <DTO.WorkerSigninList> GetIndexView(viewOptions o)
        {
            //
            var result = new dataTableResult <DTO.WorkerSigninList>();
            IQueryable <Domain.WorkerSignin> q = repo.GetAllQ();

            //
            if (o.date != null)
            {
                IndexViewBase.diffDays(o, ref q);
            }
            if (o.typeofwork_grouping != null)
            {
                IndexViewBase.typeOfWork(o, ref q);
            }
            IndexViewBase.waGrouping(o, ref q, wrServ);
            if (o.dwccardnum > 0)
            {
                IndexViewBase.dwccardnum(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            result.filteredCount = q.Count();
            result.totalCount    = repo.GetAllQ().Count();
            if (o.displayLength > 0)
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.WorkerSigninList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            return(result);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Retrieve index view of work orders
        /// </summary>
        /// <param name="vo">viewOptions object</param>
        /// <returns>Table of work orders</returns>
        public dataTableResult <DTO.WorkOrdersList> GetIndexView(viewOptions o)
        {
            //Get all the records
            var result = new dataTableResult <DTO.WorkOrdersList>();
            IQueryable <WorkOrder> q = repo.GetAllQ();

            //
            if (o.EmployerID != null)
            {
                IndexViewBase.filterEmployer(o, ref q);
            }
            if (o.employerGuid != null)
            {
                IndexViewBase.filterEmployerByGuid(o, ref q);
            }
            if (o.status != null)
            {
                IndexViewBase.filterStatus(o, ref q);
            }
            if (o.onlineSource == true)
            {
                IndexViewBase.filterOnlineSource(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }
            // TODO restore CultureInfo
            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, /*o.CI.TwoLetterISOLanguageName*/ "en", ref q);
            //
            result.filteredCount = q.Count();
            result.query         = q.ProjectTo <DTO.WorkOrdersList>(map.ConfigurationProvider)
                                   .Skip(o.displayStart)
                                   .Take(o.displayLength)
                                   .AsEnumerable();

            result.totalCount = repo.GetAllQ().Count();
            return(result);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Provide combined summary of WO/WA status
        /// </summary>
        /// <param name="search">Search text criteria</param>
        /// <param name="orderDescending">Flag indicating whether results are sorted in descending order</param>
        /// <param name="displayStart">Record to start displaying (used for pagination)</param>
        /// <param name="displayLength">Number of records to display</param>
        /// <returns>WO/WA Summary table of status counts for a given day</returns>
        public dataTableResult <WOWASummary> CombinedSummary(string search,
                                                             bool orderDescending,
                                                             int displayStart,
                                                             int displayLength)
        {
            var result = new dataTableResult <WOWASummary>();

            var q = db.Set <WOWASummary>().AsQueryable();

            if (orderDescending)
            {
                q = q.OrderByDescending(p => p.sortableDate);
            }
            else
            {
                q = q.OrderBy(p => p.sortableDate);
            }

            result.filteredCount = q.Count();
            result.query         = q.Skip <WOWASummary>((int)displayStart).Take((int)displayLength);
            result.totalCount    = GetAll().Count();
            return(result);
        }
Ejemplo n.º 12
0
        public dataTableResult <DTO.ActivityList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.ActivityList>();
            IQueryable <Activity> q = repo.GetAllQ();
            var asRepo = (IActivitySigninRepository)asServ.GetRepo();

            if (o.personID > 0 && o.attendedActivities == false)
            {
                IndexViewBase.getUnassociated(o.personID, ref q, repo, asRepo);
            }
            if (o.personID > 0 && o.attendedActivities == true)
            {
                IndexViewBase.getAssociated(o.personID, ref q, asRepo);
            }
            if (!o.authenticated)
            {
                if (o.date == null)
                {
                    o.date = DateTime.Now;
                }
                IndexViewBase.unauthenticatedView((DateTime)o.date, ref q);
            }

            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q);
            }

            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            result.filteredCount = q.Count();
            result.totalCount    = repo.GetAllQ().Count();
            result.query         = q.ProjectTo <DTO.ActivityList>(map.ConfigurationProvider)
                                   .Skip(o.displayStart)
                                   .Take(o.displayLength)
                                   .AsEnumerable();
            return(result);
        }
Ejemplo n.º 13
0
        public dataTableResult <DTO.WorkAssignmentsList> GetIndexView(viewOptions o)
        {
            var result = new dataTableResult <DTO.WorkAssignmentsList>();
            IQueryable <WorkAssignment> q = waRepo.GetAllQ();

            //
            //
            if (o.date != null)
            {
                IndexViewBase.diffDays((DateTime)o.date, ref q);
            }
            if (o.typeofwork_grouping > 0)
            {
                IndexViewBase.typeOfWork(o, ref q, lRepo);
            }
            if (o.woid > 0)
            {
                IndexViewBase.WOID(o, ref q);
            }
            if (o.personID > 0)
            {
                IndexViewBase.WID(o, ref q);
            }
            if (o.status > 0)
            {
                IndexViewBase.status(o, ref q);
            }
            if (o.showPending == false)
            {
                IndexViewBase.filterPending(o, ref q);
            }
            if (!string.IsNullOrEmpty(o.wa_grouping))
            {
                IndexViewBase.waGrouping(o, ref q, lRepo);
            }
            if (!string.IsNullOrEmpty(o.sSearch))
            {
                IndexViewBase.search(o, ref q, lRepo);
            }
            if (o.dwccardnum > 0)
            {
                var worker = wRepo.GetById((int)o.dwccardnum);
                IndexViewBase.filterOnSkill(o, q, lRepo, worker);
            }
            //Sort the Persons based on column selection
            IndexViewBase.sortOnColName(o.sortColName, o.orderDescending, ref q);
            //e = e.ToList();
            result.filteredCount = q.Count();
            if (o.displayLength > 0)
            {
                result.query = q.ProjectTo <DTO.WorkAssignmentsList>(map.ConfigurationProvider)
                               .Skip(o.displayStart)
                               .Take(o.displayLength)
                               .AsEnumerable();
            }
            else
            {
                result.query = q.ProjectTo <DTO.WorkAssignmentsList>(map.ConfigurationProvider)
                               .AsEnumerable();
            }
            result.totalCount = waRepo.GetAllQ().Count();
            return(result);
        }