Пример #1
0
        /// <summary>
        /// This method moves a worker down in numerical order in
        /// the daily ('lottery') list, and moves
        /// the proceeding (next) set member into their spot
        /// </summary>
        /// <param name="id">The Worker ID of the entry to be moved.</param>
        /// <param name="user">The username of the person making the request.</param>
        /// <returns>bool</returns>
        public bool moveDown(int id, string user)
        {
            Domain.WorkerSignin wsiDown = repo.GetById(id); // 4
            DateTime            date    = wsiDown.dateforsignin;

            int nextID = (wsiDown.lottery_sequence ?? 0) + 1; // 5

            if (nextID == 1)
            {
                return(false);
            }
            //this can't happen with current GUI settings (10/10/2013)

            Domain.WorkerSignin wsiUp = repo.GetById(
                repo.GetAllQ()
                .Where(up => up.lottery_sequence == nextID &&
                       DbFunctions.DiffDays(up.dateforsignin, date) == 0)
                .Select(g => g.ID).FirstOrDefault()
                );                                              //up.ID = 5

            int?     spotInQuestion = wsiDown.lottery_sequence; // 4
            DateTime?timeInQuestion = wsiDown.lottery_timestamp;

            wsiDown.lottery_sequence  = wsiUp.lottery_sequence; // 5
            wsiDown.lottery_timestamp = wsiUp.lottery_timestamp;
            wsiUp.lottery_sequence    = spotInQuestion;         // 4
            wsiUp.lottery_timestamp   = timeInQuestion;

            Save(wsiUp, user);
            Save(wsiDown, user);

            return(true);
        }
Пример #2
0
        /// <summary>
        /// This method moves a worker up in numerical order in
        /// the daily ('lottery') list, and moves
        /// the preceding (prior) set member into their spot
        /// </summary>
        /// <param name="id">The Worker ID of the entry to be moved.</param>
        /// <param name="user">The username of the person making the request.</param>
        /// <returns>bool</returns>
        public bool moveUp(int id, string user)
        {
            Domain.WorkerSignin wsiUp = repo.GetById(id); // 4
            DateTime            date  = wsiUp.dateforsignin;

            int prevID = (wsiUp.lottery_sequence ?? 0) - 1; // 3

            if (prevID < 1)
            {
                return(false);
            }

            Domain.WorkerSignin wsiDown = repo.GetById(
                repo.GetAllQ()
                .Where(up => up.lottery_sequence == prevID &&
                       DbFunctions.DiffDays(up.dateforsignin, date) == 0)
                .Select(g => g.ID).FirstOrDefault()
                );                                              //down.lotSq = 3

            int?     spotInQuestion = wsiDown.lottery_sequence; // 3
            DateTime?timeInQuestion = wsiDown.lottery_timestamp;

            wsiDown.lottery_sequence  = wsiUp.lottery_sequence; // 4
            wsiDown.lottery_timestamp = wsiUp.lottery_timestamp;
            wsiUp.lottery_sequence    = spotInQuestion;         // 3
            wsiUp.lottery_timestamp   = timeInQuestion;         // down.lotSq = 4

            Save(wsiUp, user);
            Save(wsiDown, user);

            return(true);
        }
Пример #3
0
        /// <summary>
        /// Retrieve active orders for a given day. Active and assigned OR all active
        /// </summary>
        /// <param name="date">filter for the date</param>
        /// <param name="assignedOnly">filter to only orders with fully assigned jobs</param>
        /// <returns>WorkOrders associated with a given date that are active</returns>
        public IEnumerable <WorkOrder> GetActiveOrders(DateTime date, bool assignedOnly)
        {
            IQueryable <WorkOrder> query = repo.GetAllQ();

            query = query.Where(wo => wo.statusID == WorkOrder.iActive &&
                                DbFunctions.DiffDays(wo.dateTimeofWork, date) == 0 ? true : false)
                    .AsQueryable();
            List <WorkOrder> list  = query.ToList();
            List <WorkOrder> final = list.ToList();

            if (!assignedOnly)
            {
                return(final);
            }
            int waCounter = 0;

            foreach (WorkOrder wo in list)
            {
                waCounter = 0;
                foreach (WorkAssignment wa in wo.workAssignments)
                {
                    waCounter++;
                    if (wa.workerAssignedID == null)
                    {
                        final.Remove(wo);
                        break;
                    }
                }
                if (waCounter == 0) // WO must have at least one WA to be completed
                {
                    final.Remove(wo);
                }
            }
            return(final);
        }
Пример #4
0
        public static void search(viewOptions o, ref IQueryable <WorkOrder> q)
        {
            bool     isDateTime = false;
            DateTime parsedTime;

            if (isDateTime = DateTime.TryParse(o.sSearch, out parsedTime))
            {
                if (isMonthSpecific.IsMatch(o.sSearch))  //Regex for month/year
                {
                    q = q.Where(p => DbFunctions.DiffMonths(p.dateTimeofWork, parsedTime) == 0 ? true : false);
                }
                if (isDaySpecific.IsMatch(o.sSearch))  //Regex for day/month/year
                {
                    q = q.Where(p => DbFunctions.DiffDays(p.dateTimeofWork, parsedTime) == 0 ? true : false);
                }
                if (isTimeSpecific.IsMatch(o.sSearch)) //Regex for day/month/year time
                {
                    q = q.Where(p => DbFunctions.DiffHours(p.dateTimeofWork, parsedTime) == 0 ? true : false);
                }
            }
            else
            {
                q = q
                    .Where(p => SqlFunctions.StringConvert((decimal)p.ID).Contains(o.sSearch) ||
                           SqlFunctions.StringConvert((decimal)p.paperOrderNum).Contains(o.sSearch) ||
                           p.contactName.Contains(o.sSearch) ||
                           p.workSiteAddress1.Contains(o.sSearch) ||
                           p.updatedby.Contains(o.sSearch));
            }
        }
Пример #5
0
 /// <summary>
 /// Filter WA queryable on a partial date string
 /// </summary>
 /// <param name="search">string that is part of a date</param>
 /// <param name="parsedTime">datetime.parse of the same string</param>
 /// <param name="query">WorkAssignment queryable</param>
 public static void filterOnDatePart(string search, DateTime parsedTime, ref IQueryable <WorkAssignment> query)
 {
     if (isMonthSpecific.IsMatch(search))  //Regex for month/year
     {
         query = query.Where(p => DbFunctions.DiffMonths(p.workOrder.dateTimeofWork, parsedTime) == 0 ? true : false);
     }
     if (isDaySpecific.IsMatch(search))  //Regex for day/month/year
     {
         query = query.Where(p => DbFunctions.DiffDays(p.workOrder.dateTimeofWork, parsedTime) == 0 ? true : false);
     }
     if (isTimeSpecific.IsMatch(search)) //Regex for day/month/year time
     {
         query = query.Where(p => DbFunctions.DiffHours(p.workOrder.dateTimeofWork, parsedTime) == 0 ? true : false);
     }
     //throw new ArgumentException("Date string not valid for Month,Day, or Hour pattern");
 }
Пример #6
0
        public static void diffDays(viewOptions o, ref IQueryable <WorkAssignment> q)
        {
            DateTime sunday;

            if (o.date.Value.DayOfWeek == DayOfWeek.Saturday)
            {
                sunday = o.date.Value.AddDays(1);
                q      = q.Where(p => DbFunctions.DiffDays(p.workOrder.dateTimeofWork, o.date) == 0 ? true : false ||
                                 DbFunctions.DiffDays(p.workOrder.dateTimeofWork, sunday) == 0 ? true : false
                                 );
            }
            else
            {
                q = q.Where(p => DbFunctions.DiffDays(p.workOrder.dateTimeofWork, o.date) == 0 ? true : false);
            }
        }
Пример #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <param name="search"></param>
        /// <returns></returns>
        public static IQueryable <WorkOrder> filterDateTimeOfWork(IQueryable <WorkOrder> query, string search)
        {
            //Using DateTime.TryParse as determiner of date/string
            DateTime parsedTime;

            if (DateTime.TryParse(search, out parsedTime))
            {
                if (isMonthSpecific.IsMatch(search))  //Regex for month/year
                {
                    return(query.Where(p => DbFunctions.DiffMonths(p.dateTimeofWork, parsedTime) == 0 ? true : false));
                }
                if (isDaySpecific.IsMatch(search))  //Regex for day/month/year
                {
                    return(query.Where(p => DbFunctions.DiffDays(p.dateTimeofWork, parsedTime) == 0 ? true : false));
                }
                if (isTimeSpecific.IsMatch(search)) //Regex for day/month/year time
                {
                    return(query.Where(p => DbFunctions.DiffHours(p.dateTimeofWork, parsedTime) == 0 ? true : false));
                }
            }
            return(query);
        }
Пример #8
0
 public static void diffDays <T>(viewOptions o, ref IQueryable <T> q) where T : Signin
 {
     q = q.Where(p => DbFunctions.DiffDays(p.dateforsignin, o.date) == 0 ? true : false);
 }
Пример #9
0
 /// <summary>
 /// This method counts the current lottery (daily list) entries for the day and increments by one.
 /// </summary>
 /// <param name="date">The date for sequencing.</param>
 /// <returns>int</returns>
 public int GetNextLotterySequence(DateTime date)
 {
     return(repo.GetAllQ().Where(p => p.lottery_timestamp != null &&
                                 DbFunctions.DiffDays(p.dateforsignin, date) == 0 ? true : false)
            .Count() + 1);
 }
Пример #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="dwccardnum"></param>
 /// <param name="date"></param>
 /// <returns>WorkerSignin</returns>
 public Domain.WorkerSignin GetSignin(int dwccardnum, DateTime date)
 {
     return(repo.GetAllQ().FirstOrDefault(r => r.dwccardnum == dwccardnum &&
                                          DbFunctions.DiffDays(r.dateforsignin, date) == 0 ? true : false));
 }