Beispiel #1
0
        private void LockEvent(EventType eventType, string awardName)
        {
            var day = ConfigurationManager.AppSettings["FirstDayOfCurrentMonth"];
            var firstDayOfCurrentMonth = new DateTime(System.DateTime.Now.Year, System.DateTime.Now.Month, Convert.ToInt32(day));

            _logger.Log("EncourageEventProcessor-LockEvent");

            using (HolidayService holidayService = new HolidayService())
            {
                var holidays = holidayService.GetCurrentMonthHolidays();
                switch (eventType)
                {
                    #region Lock Nomination
                case EventType.LockNomination:
                    var      managerDays           = Convert.ToInt32(ConfigurationManager.AppSettings["NoOfDaysManager"]);
                    DateTime lastDateForNomination = firstDayOfCurrentMonth.AddDays(Convert.ToDouble(ConfigurationManager.AppSettings["NoOfDaysManager"].ToString()));

                    if (holidays.Any())
                    {
                        var fallingHolidaysForManager = from holidaysInRange in holidays
                                                        where holidaysInRange <= managerDays
                                                        select holidaysInRange;

                        var count2 = fallingHolidaysForManager.Count();
                        lastDateForNomination = lastDateForNomination.AddDays(count2);
                    }

                    if (System.DateTime.Now == lastDateForNomination || System.DateTime.Now > lastDateForNomination)
                    {
                        LockNomination(awardName);
                    }
                    break;
                    #endregion

                    #region Lock Review
                case EventType.LockReview:
                    int count           = 0;
                    var noOfDaysManager = Convert.ToInt32(ConfigurationManager.AppSettings["NoOfDaysManager"]);

                    if (holidays.Any())
                    {
                        var fallingHoliday = from holidaysInRange in holidays
                                             where holidaysInRange <= noOfDaysManager
                                             select holidaysInRange;

                        count = fallingHoliday.Count();
                    }

                    var dayCount = 0;
                    noOfDaysManager += count;
                    var noOfDaysReviewer   = Convert.ToInt32(ConfigurationManager.AppSettings["NoOfDaysReviewer"]);
                    var expireDateReviewer = firstDayOfCurrentMonth.AddDays(Convert.ToDouble(System.Configuration.ConfigurationManager.AppSettings["NoOfDaysReviewer"].ToString()) + noOfDaysManager);
                    var reviewercount      = expireDateReviewer.Day;
                    var reviewerdays       = reviewercount - noOfDaysReviewer;

                    if (holidays.Any())
                    {
                        var fallingHolidaysReviewer = from fallingHolidaysReviewerInRange in holidays
                                                      where fallingHolidaysReviewerInRange <= reviewercount && fallingHolidaysReviewerInRange >= reviewerdays
                                                      select fallingHolidaysReviewerInRange;

                        if (fallingHolidaysReviewer.Any())
                        {
                            dayCount = fallingHolidaysReviewer.Count();
                        }

                        expireDateReviewer = expireDateReviewer.AddDays(dayCount);
                    }

                    if (System.DateTime.Now == expireDateReviewer || System.DateTime.Now > expireDateReviewer)
                    {
                        LockReview(awardName);
                    }
                    break;

                    #endregion
                default:
                    break;
                }
            }
        }