Example #1
0
        public ActionResult Index(int week, int year, bool completed = false)
        {
            //doing the sync here, which is ugly, but will have to suffice until I found a way to do it in the background.
            //2014-09-06: using CloudScheduler now so I can stop doing this!
            //NflSync.UpdateGames("http://www.nfl.com/liveupdate/scorestrip/ss.xml");

            var vm = new WeekIndex();

            vm.CurrentWeek = new Week(week, year);

            //get all of the weeks
            vm.Weeks = (from g in db.Games
                        where g.Year == year && g.GameType == "REG"
                        select new Week
            {
                WeekNumber = g.Week,
                Year = g.Year
            }).Distinct().ToList();

            if (DateTime.Now > PickemApp.Models.Season.GetDeadline(week, year))
            {
                var listLeaders = WeeklyPlayerPicks.GetWeeklyLeaders(week, year, completed);
                vm.Leaders = listLeaders.ToList();
            }

            var games = db.Games.Where(q => q.Week == week && q.Year == year && q.GameType == "REG").ToList();

            vm.Games = games.OrderBy(o => o.Eid.Substring(0, 8)).ThenBy(o => o.Time.PadLeft(5, '0')).ThenBy(o => o.Gsis).ToList();

            return(View(vm));
        }
        private bool calcComplexReceiptPlan(bool debug = false)
        {
            SqlPipe sqlP = SqlContext.Pipe;
            int     step = 0;

            if (debug)
            {
                sqlP.Send(" calcComplexReceiptPlan Step " + step++);
            }

            decimal[] cumulativeReceiptNeeds = CalcNodeReceiptNeeds();

            Dictionary <Tuple <int, int>, decimal> priorAllocation = new Dictionary <Tuple <int, int>, decimal>();

            if (debug)
            {
                sqlP.Send(" calcComplexReceiptPlan Step " + step++);
            }

            int earliestStartWeekIndex = -1;

            if (BOH == 0 && FirstSalesWeek < FirstReceiptWeek)
            {
                if (!WeekIndex.TryGetValue(FirstReceiptWeek, out earliestStartWeekIndex))
                {
                    return(false);
                }
            }
            if (debug)
            {
                sqlP.Send(" calcComplexReceiptPlan Step " + step++);
            }
            // Assign BOH
            bool success           = true;
            int  criticalWeekIndex = 0;
            int  qty = 0;

            if (BOH > 0)
            {
                qty      = BOH;
                success &= allocate(qty, null, priorAllocation, earliestStartWeekIndex, cumulativeReceiptNeeds, ref criticalWeekIndex);
            }
            if (debug)
            {
                sqlP.Send(" calcComplexReceiptPlan - BOH - Step " + step++);
            }

            foreach (Receipt receipt in Receipts)
            {
                qty     += receipt.Qty;
                success &= allocate(qty, receipt, priorAllocation, earliestStartWeekIndex, cumulativeReceiptNeeds, ref criticalWeekIndex);
                if (debug)
                {
                    sqlP.Send(" calcComplexReceiptPlan - allocate receipt -  Step " + step++);
                }
            }

            return(success);
        }
Example #3
0
        /// <summary>Initializes a new instance of the <see cref="MonthWeekdayHoliday"/> class.
        /// </summary>
        /// <param name="holidayName">The (language independent) name of the holiday in its <see cref="IdentifierString"/> representation.</param>
        /// <param name="dayOfWeek">The day of week with respect to the represented holiday.</param>
        /// <param name="month">The month with respect to the represented holiday.</param>
        /// <param name="week">The index of the week with respect to the represented holiday and the corresponding <paramref name="month"/>.</param>
        /// <param name="firstYear">The first year to take into account the holiday.</param>
        /// <param name="lastYear">The last year to take into account the holiday.</param>
        /// <param name="holidayLongName">The (language dependent) long name of the holiday.</param>
        /// <exception cref="ArgumentNullException">Thrown, if <paramref name="holidayName"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown, if <paramref name="dayOfWeek"/> represents a saturday or sunday.</exception>
        public MonthWeekdayHoliday(IdentifierString holidayName, DayOfWeek dayOfWeek, Month month, WeekIndex week, int firstYear = Int32.MinValue, int lastYear = Int32.MaxValue, IdentifierString holidayLongName = null)
        {
            if (holidayName == null)
            {
                throw new ArgumentNullException("holidayName");
            }
            Name     = holidayName;
            LongName = (holidayLongName != null) ? holidayLongName : holidayName;
            if ((dayOfWeek == System.DayOfWeek.Saturday) || (dayOfWeek == System.DayOfWeek.Sunday))
            {
                throw new ArgumentException("No saturdays or sundays allowed.", "dayOfWeek");
            }
            DayOfWeek = (int)dayOfWeek;
            Month     = (int)month;
            Week      = (int)week;

            FirstYear = firstYear;
            LastYear  = lastYear;
        }