Exemplo n.º 1
0
        public ActionResult Newsletter(CommunicationsContext context)
        {
            var employer = _employersQuery.GetEmployer(context.UserId);

            if (employer == null)
            {
                return(HttpNotFound());
            }

            // Other enabled employers in the same organisation.

            var organisationHierarchy = _organisationsQuery.GetOrganisationHierarchy(employer.Organisation.Id);
            var employerIds           = _recruitersQuery.GetRecruiters(organisationHierarchy);

            employerIds = _userAccountsQuery.GetEnabledAccountIds(employerIds);

            var lastLastLastMonth = new MonthRange(DateTime.Now.AddMonths(-3));
            var lastLastMonth     = new MonthRange(DateTime.Now.AddMonths(-2));
            var lastMonth         = new MonthRange(DateTime.Now.AddMonths(-1));

            var model = CreateModel <NewsletterModel>(context);

            model.LoginId          = _loginCredentialsQuery.GetLoginId(employer.Id);
            model.Employer         = employer;
            model.SampleSearches   = GetCachedSampleSearches();
            model.PreviousSearches = GetPreviousSearches(employer, employerIds, lastMonth);
            model.Ranks            = GetRanks(employer.Id, employerIds, lastLastLastMonth, lastLastMonth, lastMonth);
            return(View(model));
        }
Exemplo n.º 2
0
        private IList <NewsletterSearchModel> GetSampleSearches()
        {
            var lastMonth       = new MonthRange(DateTime.Now.AddMonths(-1));
            var availableNow    = _candidateReportsQuery.GetCandidateStatuses(CandidateStatus.AvailableNow);
            var activelyLooking = _candidateReportsQuery.GetCandidateStatuses(CandidateStatus.ActivelyLooking);
            var indigenous      = (_candidateReportsQuery.GetEthnicStatuses(EthnicStatus.Aboriginal).Concat(_candidateReportsQuery.GetEthnicStatuses(EthnicStatus.TorresIslander)).Distinct()).ToList();

            // Statuses.

            var searches = new List <NewsletterSearchModel>();

            AddSearch(searches, "Immediately available", availableNow, lastMonth);
            AddSearch(searches, "Actively looking", activelyLooking, lastMonth);
            AddSearch(searches, "Indigenous", indigenous, lastMonth);

            // Keywords.

            foreach (var keywords in Keywords)
            {
                var criteria = new MemberSearchCriteria();
                criteria.SetKeywords(keywords);
                AddSearch(searches, null, criteria, lastMonth);
            }

            return(searches);
        }
Exemplo n.º 3
0
 private void OnMonthChanged(MonthRange args)
 {
     if (BindingContext is MainPageViewModel viewModel)
     {
         viewModel.GetEventsByRange(args.Start, args.End);
     }
 }
Exemplo n.º 4
0
        public void RemoveRanges_RangeNot_IntersectedWithMain_Exception()
        {
            var target         = new MonthRange(new Date(2020, 12, 1), new Date(2020, 12, 15));
            var rangesToRemove = new List <TimeRange>
            {
                new TimeRange(new Date(2020, 11, 16), new Date(2020, 11, 28))
            };

            Assert.Throws <InvalidOperationException>(() => target.RemoveRanges(rangesToRemove));
        }
Exemplo n.º 5
0
        public void Ctor_SameMonths_Ok(int start, int end, int daysCountExpected)
        {
            var target = new MonthRange(
                new Date(2020, 6, start),
                new Date(2020, 6, end));

            Assert.Equal(2020, target.Year);
            Assert.Equal(6, target.Month);
            Assert.Equal(daysCountExpected, target.DaysCount);
        }
Exemplo n.º 6
0
        protected override bool OnVisitYear(YearRange year, CalendarPeriodCollectorContext context)
        {
            if (IsDebugEnabled)
            {
                log.Debug("Visit Year... year=[{0}]", year);
            }

            if (context.Scope != CalendarPeriodCollectorContext.CollectKind.Month)
            {
                return(true); // continue
            }

            // all month
            if (Filter.CollectingMonths.Count == 0)
            {
                var months = year.GetMonths().Where(m => IsMatchingMonth(m, context) && CheckLimits(m));

                _periods.AddAll(months.Cast <ITimePeriod>().AsEnumerable());
            }
            else
            {
                var months =
                    Filter.CollectingMonths
                    .Select(m => {
                    if (m.IsSingleMonth)
                    {
                        var month = new MonthRange(year.YearValue, m.Min, year.TimeCalendar);
                        if (IsMatchingMonth(month, context) && CheckLimits(month))
                        {
                            return((ITimePeriod)month);
                        }
                    }
                    else
                    {
                        var monthRanges = new MonthRangeCollection(year.YearValue, m.Min, m.Max - m.Min,
                                                                   year.TimeCalendar);
                        var isMatching = monthRanges.GetMonths().All(month => IsMatchingMonth(month, context));

                        if (isMatching && CheckLimits(monthRanges))
                        {
                            return((ITimePeriod)monthRanges);
                        }
                    }
                    return((ITimePeriod)null);
                })
                    .Where(m => m != null);

                _periods.AddAll(months.Cast <ITimePeriod>().AsEnumerable());
            }

            return(false); // abort
        }
Exemplo n.º 7
0
        protected override bool OnVisitMonth(MonthRange month, CalendarPeriodCollectorContext context)
        {
            if (IsDebugEnabled)
            {
                log.Debug("Month[{0}]를 탐색합니다...", month);
            }

            if (context.Scope != CalendarPeriodCollectorContext.CollectKind.Day)
            {
                return(true); // continue
            }

            // all month
            if (Filter.CollectingDays.Count == 0)
            {
                var days = month.GetDays().Where(d => IsMatchingDay(d, context) && CheckLimits(d));
                _periods.AddAll(days.Cast <ITimePeriod>().AsEnumerable());
            }
            else
            {
                var days =
                    Filter.CollectingDays
                    .Select(day => {
                    if (day.IsSingleDay)
                    {
                        var dayRange = new DayRange(month.Year, month.Month, day.Min, month.TimeCalendar);
                        if (IsMatchingDay(dayRange, context) && CheckLimits(dayRange))
                        {
                            return(dayRange);
                        }
                    }
                    else
                    {
                        var dayRanges = new DayRangeCollection(month.Year, month.Month, day.Min, day.Max - day.Min,
                                                               month.TimeCalendar);
                        var isMatching = dayRanges.GetDays().All(d => IsMatchingDay(d, context));

                        if (isMatching && CheckLimits(dayRanges))
                        {
                            return((ITimePeriod)dayRanges);
                        }
                    }
                    return(null);
                })
                    .Where(d => d != null);

                _periods.AddAll(days.Cast <ITimePeriod>().AsEnumerable());
            }

            return(false); // abort
        }
Exemplo n.º 8
0
        public void RemoveRanges_RangeFullyCover_MainRange_Ok()
        {
            var target            = new MonthRange(new Date(2020, 12, 1), new Date(2020, 12, 2));
            var vacationTimeRange = new TimeRange(new Date(2020, 11, 25), new Date(2020, 12, 5));

            var rangesToRemove = new List <TimeRange>
            {
                vacationTimeRange
            };

            var ranges = target.RemoveRanges(rangesToRemove);

            Assert.Empty(ranges);
        }
Exemplo n.º 9
0
        protected virtual bool IsMatchingMonth(MonthRange month, TContext context)
        {
            if (Filter.Years.Count > 0 && Filter.Years.Contains(month.Year) == false)
            {
                return(false);
            }

            if (Filter.Months.Count > 0 && Filter.Months.Contains(month.Month) == false)
            {
                return(false);
            }

            return(CheckExcludePeriods(month));
        }
Exemplo n.º 10
0
        public void PeriodOutsideTouchingLimitsTest()
        {
            var limits        = new MonthRange(2011, 3); // new TimeRange(new DateTime(2011, 3, 1), new DateTime(2011, 3, 31));
            var gapCalculator = new TimeGapCalculator <TimeRange>();

            var excludePeriods = new TimePeriodCollection
            {
                new TimeRange(new DateTime(2011, 2, 1), new DateTime(2011, 3, 5)),
                new TimeRange(new DateTime(2011, 3, 20), new DateTime(2011, 4, 15))
            };

            var gaps = gapCalculator.GetGaps(excludePeriods, limits);

            gaps.Count.Should().Be(1);
            gaps[0].IsSamePeriod(new TimeRange(new DateTime(2011, 3, 5), new DateTime(2011, 3, 20))).Should().Be.True();
        }
Exemplo n.º 11
0
        public void RemoveRanges_NotAllRangesIncludedIntoMainOne_Case2_Ok()
        {
            var target = new MonthRange(new Date(2020, 6, 1), new Date(2020, 6, 30));

            var rangesToRemove = new List <TimeRange>
            {
                new TimeRange(new Date(2020, 5, 15), new Date(2020, 6, 14)),
            };

            var ranges = target.RemoveRanges(rangesToRemove);

            Assert.Single(ranges);

            var newTimeRange = new TimeRange(new Date(2020, 6, 15), new Date(2020, 6, 30));

            Assert.Equal(newTimeRange.From, ranges.First().From);
            Assert.Equal(newTimeRange.To, ranges.First().To);
        }
Exemplo n.º 12
0
        public void RemoveRanges_RangeIntersect_WithMainRange_Ok()
        {
            var target            = new MonthRange(new Date(2020, 11, 5), new Date(2020, 11, 30));
            var vacationTimeRange = new TimeRange(new Date(2020, 11, 25), new Date(2020, 12, 5));

            var rangesToRemove = new List <TimeRange>
            {
                vacationTimeRange
            };

            var ranges = target.RemoveRanges(rangesToRemove);

            Assert.Single(ranges);
            var range = ranges.First();

            Assert.Equal(target.From, range.From);
            Assert.Equal(new Date(vacationTimeRange.From.AddDays(-1)).EndOfTheDay(), range.To);
        }
Exemplo n.º 13
0
        public void RemoveRanges_AllRangesIncludedIntoMainOne_Case1_Ok()
        {
            var target = new MonthRange(new Date(2020, 6, 1), new Date(2020, 6, 30));

            var rangesToRemove = new List <TimeRange>
            {
                new TimeRange(new Date(2020, 6, 1), new Date(2020, 6, 10))
            };

            IReadOnlyCollection <TimeRange> result = target.RemoveRanges(rangesToRemove);

            Assert.Single(result);

            var first = result.First();

            Assert.True(new Date(2020, 6, 11).SameDay(first.From));
            Assert.True(new Date(2020, 6, 30).SameDay(first.To));
        }
Exemplo n.º 14
0
        public void RemoveRanges_AllRangesIncludedIntoMainOne_Case3_Ok()
        {
            var target = new MonthRange(new Date(2020, 6, 1), new Date(2020, 6, 30));

            var rangesToRemove = new List <TimeRange>
            {
                new TimeRange(new Date(2020, 6, 1), new Date(2020, 6, 1)),
                new TimeRange(new Date(2020, 6, 10), new Date(2020, 6, 20)),
                new TimeRange(new Date(2020, 6, 28), new Date(2020, 6, 30))
            };

            IReadOnlyCollection <TimeRange> result = target.RemoveRanges(rangesToRemove);

            Assert.Equal(2, result.Count);

            Assert.True(new Date(2020, 6, 2).SameDay(result.ElementAt(0).From));
            Assert.True(new Date(2020, 6, 9).SameDay(result.ElementAt(0).To));

            Assert.True(new Date(2020, 6, 21).SameDay(result.ElementAt(1).From));
            Assert.True(new Date(2020, 6, 27).SameDay(result.ElementAt(1).To));
        }
Exemplo n.º 15
0
        protected MonthRange StartMonthVisit(MonthRange month, TContext context, SeekDirection?visitDirection = null)
        {
            month.ShouldNotBeNull("month");
            var direction = visitDirection ?? SeekDirection;

            if (IsDebugEnabled)
            {
                log.Debug("Month 단위로 탐색합니다. month=[{0}], context=[{1}], direction=[{2}]", month, context, direction);
            }

            MonthRange lastVisited = null;

            OnVisitStart();

            var minStart = DateTime.MinValue;
            var maxEnd   = DateTime.MaxValue.AddYears(-1);
            var offset   = (direction == SeekDirection.Forward) ? 1 : -1;

            while (month.Start > minStart && month.End < maxEnd)
            {
                if (OnVisitMonth(month, context) == false)
                {
                    lastVisited = month;
                    break;
                }

                month = month.AddMonths(offset);
            }

            OnVisitEnd();

            if (IsDebugEnabled)
            {
                log.Debug("마지막 탐색 Month. lastVisited=[{0}]", lastVisited);
            }

            return(lastVisited);
        }
Exemplo n.º 16
0
        public void RemoveRanges_RangeInMainRange_Ok()
        {
            var target            = new MonthRange(new Date(2020, 11, 5), new Date(2020, 11, 30));
            var vacationTimeRange = new TimeRange(new Date(2020, 11, 16), new Date(2020, 11, 28));

            var rangesToRemove = new List <TimeRange>
            {
                vacationTimeRange
            };

            var ranges = target.RemoveRanges(rangesToRemove);

            Assert.Equal(2, ranges.Count());
            var firstRange = ranges.First();

            Assert.Equal(target.From, firstRange.From);
            Assert.Equal(new Date(vacationTimeRange.From.AddDays(-1)).EndOfTheDay(), firstRange.To);

            var secondRange = ranges.Last();

            Assert.Equal(new Date(vacationTimeRange.To.AddDays(1)).StartOfTheDay(), secondRange.From);
            Assert.Equal(new Date(target.To).EndOfTheDay(), secondRange.To);
        }
Exemplo n.º 17
0
 protected virtual bool OnVisitMonth(MonthRange month, TContext context)
 {
     return(true);
 }
Exemplo n.º 18
0
 protected virtual bool EnterDays(MonthRange month, TContext context)
 {
     return(true);
 }
Exemplo n.º 19
0
 protected override bool EnterDays(MonthRange month, DaySeekerContext context)
 {
     return(!context.IsFinished);
 }
Exemplo n.º 20
0
        public void RemoveRanges_NoRangesToRemove_Exception()
        {
            var target = new MonthRange(new Date(2020, 6, 1), new Date(2020, 6, 30));

            Assert.Throws <InvalidOperationException>(() => target.RemoveRanges(Array.Empty <TimeRange>()));
        }
Exemplo n.º 21
0
 protected override bool EnterDays(MonthRange month, CalendarPeriodCollectorContext context)
 {
     return((int)context.Scope > (int)CalendarPeriodCollectorContext.CollectKind.Day);
 }
Exemplo n.º 22
0
        public void RemoveRanges_Null_Exception()
        {
            var target = new MonthRange(new Date(2020, 6, 1), new Date(2020, 6, 30));

            Assert.Throws <ArgumentNullException>(() => target.RemoveRanges(null));
        }
Exemplo n.º 23
0
 private void OnMonthChanged(MonthRange monthRange)
 {
     StartDate.Text = monthRange.Start.ToString("G");
     EndDate.Text   = monthRange.End.ToString("G");
 }
Exemplo n.º 24
0
        public ActionResult Details(int?id)
        {
            if (id != null)
            {
                ViewBag.canCRUD = false;
                CustomRole customeRole = new CustomRole();
                ViewBag.canCRUD = customeRole.IsUserInRole(User.Identity.Name, RoleNames.PPC) || customeRole.IsUserInRole(User.Identity.Name, RoleNames.SuperAdmin);//canCRUD;

                DateTime startDate = DateTime.Now.AddMonths(-1);
                startDate = startDate.AddMilliseconds(0 - startDate.Millisecond);
                startDate = startDate.AddSeconds(0 - startDate.Second);
                startDate = startDate.AddMinutes(0 - startDate.Minute);
                startDate = startDate.AddHours(0 - startDate.Hour);
                startDate = startDate.AddDays(1 - startDate.Day);
                DateTime endDate = DateTime.Now.AddMonths(4);


                MPSViewModel mpsData = new MPSViewModel();
                List <PRO>   listPRO = new List <PRO>();

                ProductGroup groupProductData = db.ProductGroups.Find(id);
                ViewBag.GroupProductName = groupProductData.Name;
                ViewBag.week             = 0;
                ViewBag.tanggal          = DateTime.Now;
                ViewBag.ReasonIssue      = new SelectList(db.ReasonIssues, "ID", "Name");

                #region CountHolidayTotalInRange
                List <DateTime> holidayDateList = db.HolidayDetails.Where(x => startDate >= x.HolidayDate && endDate <= x.HolidayDate).Select(x => x.HolidayDate).Distinct().ToList();

                int totalHoliday = 0;
                foreach (DateTime item in holidayDateList)
                {
                    if (item.DayOfWeek != DayOfWeek.Saturday && item.DayOfWeek != DayOfWeek.Sunday)
                    {
                        totalHoliday++;
                    }
                }
                #endregion

                #region SetWeekNumberDataHeaderForEachMonth
                CultureInfo ci          = new CultureInfo("en-US");
                DateTime    incDateTime = startDate;
                do
                {
                    MonthRange monthRangeData = new MonthRange();
                    //int? currentCapacity
                    ProductGroupCapacity productGroupCapacity = groupProductData.ProductGroupCapacities.Where(x => x.StartMonth.AddDays(1 - x.StartMonth.Day).Date <= incDateTime.Date).OrderByDescending(o => o.StartMonth).FirstOrDefault();
                    monthRangeData.Month            = incDateTime.Month;
                    monthRangeData.Year             = incDateTime.Year;
                    monthRangeData.MonthDisplayText = incDateTime.ToString("MMMM", ci) + " " + incDateTime.Year.ToString();
                    monthRangeData.WeekNumberList.AddRange(GetWeekNumberListofMonths(incDateTime.Month, incDateTime.Year));
                    monthRangeData.Capacity = null;
                    if (productGroupCapacity != null)
                    {
                        monthRangeData.Capacity = productGroupCapacity.Capacity;
                    }
                    mpsData.MonthRangeList.Add(monthRangeData);
                    incDateTime = incDateTime.AddMonths(1);
                } while (incDateTime <= endDate);
                #endregion

                listPRO = db.Pros.Where(x => x.Products.ProductSubGroups.ProductGroup.ID == id).ToList();
                listPRO = listPRO.Where(x => x.DueDate.Date >= startDate.Date).OrderBy(x => x.Products.Name).ThenBy(x => x.DueDate).ToList();


                #region setPROMinimunDueDate
                foreach (PRO item in listPRO)
                {
                    int processDay = 0;
                    int pbDays     = 0;

                    if (item.Products.ProductComposition.Count() > 0)
                    {
                        pbDays = 10;
                    }

                    DateTime currentDateTime = DateTime.Now;
                    if (item.Products.TotalDay != null)
                    {
                        processDay = (int)item.Products.TotalDay + pbDays;
                    }
                    int totalWeek = (processDay / 5);
                    int sisaHari  = processDay % 5;

                    currentDateTime = currentDateTime.AddDays(processDay + (totalWeek * 2) + totalHoliday);

                    item.MinimumDueDate = currentDateTime;

                    DateTime currentMonthFirstDate                     = startDate.AddMonths(1);
                    int      totalActualUnitUntilCurrentMonth          = item.Units.Where(x => x.ActualDeliveryDate < currentMonthFirstDate).Count();
                    int      totalActualUnitUntilLastMonth             = item.Units.Where(x => x.ActualDeliveryDate < startDate).Count();
                    List <MasterPlanSchedule> listMPSUntilCurrentMonth = item.MasterPlanSchedules.Where(x => x.EndWorkingDate < currentMonthFirstDate).ToList();
                    List <MasterPlanSchedule> listMPSUntilLastMonth    = listMPSUntilCurrentMonth.Where(x => x.EndWorkingDate < startDate).ToList();
                    int totalPlanUntilCurrentMonth                     = listMPSUntilCurrentMonth.Sum(x => x.CurrentPlannedQuantity);
                    int totalPlanUntilLastMonth = listMPSUntilLastMonth.Sum(x => x.CurrentPlannedQuantity);

                    item.CurrentMonthCarryOver = totalPlanUntilCurrentMonth - totalActualUnitUntilCurrentMonth;
                    item.LastMonthCarryOver    = totalPlanUntilLastMonth - totalActualUnitUntilLastMonth;

                    item.MaximumPlanQuantity = item.UnHoldUnitCount - item.Units.Where(x => x.MPSDueDate < startDate && x.IsHold == false).Count();
                }
                #endregion
                //listPRO = listPRO.OrderBy(x => x.Product.Name).ThenBy(x => x.DueDate).ToList();
                mpsData.PROList        = listPRO;
                ViewBag.TotalCarryOver = listPRO.Sum(x => x.LastMonthCarryOver);
                ViewBag.TestPesan      = debugViewMessage;

                return(View(mpsData));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }