public GoalTemplateInfo(int id, string name, string details, DTC.RangeEnum range)
 {
     this.id      = id;
     this.name    = name;
     this.details = details;
     this.range   = range;
 }
        public IEnumerable <GoalInfo> Get(int rangeID, string strDateStart, string strDateEnd, bool isGetPresentValues)
        {
            DateTime dtStart = DateTime.Today;
            DateTime dtEnd   = DateTime.Today;

            DTC.RangeEnum range = (DTC.RangeEnum)rangeID;
            if (strDateStart != string.Empty)
            {
                dtStart = DTC.Date.GetDateFromString(strDateStart, DTC.Date.DateStyleEnum.Universal);
            }

            if (strDateEnd != string.Empty)
            {
                dtEnd = DTC.Date.GetDateFromString(strDateEnd, DTC.Date.DateStyleEnum.Universal);
            }

            List <GoalInfo> goals = DB.Goals.GetImportantGoals(range, dtStart, dtEnd, isGetPresentValues).FindAll(i => i.IsFocus);

            DayInfo day = DB.Days.GetDay(DateTime.Today, true);

            foreach (GoalInfo goal in goals)
            {
                goal.PresentPercentage = goal.GetPerformance(false, day);
                goal.DesiredValue      = goal.GetDesiredValue(day);
            }

            goals = goals.OrderByDescending(i => i.PresentPercentage).ToList();

            return(goals);
        }
 public GoalTemplateInfo()
 {
     id      = 0;
     name    = "";
     details = "";
     range   = DTC.RangeEnum.Floating;
 }
示例#4
0
 public OwnerInfo()
 {
     ownerID   = 0;
     range     = DTC.RangeEnum.Floating;
     startDate = DateTime.Today;
     endDate   = DateTime.Today;
     no        = 0;
     label     = "";
 }
示例#5
0
        public IEnumerable <GoalInfo> Get(int rangeID, int numItems, bool isIncludeBetweenLimitGoals)
        {
            DTC.RangeEnum        range      = (DTC.RangeEnum)rangeID;
            OwnerInfo            owner      = DB.Owner.GetOwner(range, DateTime.Today);
            List <GoalInfo>      goalsAll   = DB.Goals.GetGoals(owner, true);
            List <GoalGroupInfo> goalGroups = DB.Goals.GetGoalGroups();

            List <GoalInfo> goalsPicked = new List <GoalInfo>();
            DayInfo         today       = DB.Days.GetDay(DateTime.Today, true);
            GoalsEngine     goalEngine  = new GoalsEngine(goalsAll, goalGroups, today);

            if (!isIncludeBetweenLimitGoals)
            {
                goalsAll = goalsAll.FindAll(i => i.Nature == GoalInfo.NatureEnum.Standart);
            }

            foreach (GoalInfo goal in goalsAll)
            {
                goal.Contribution    = goalEngine.GetGoalContributionWeighted(goal, false, GoalsEngine.PerformanceNatureEnum.Worst);
                goal.ContributionMax = goalEngine.GetGoalContributionWeighted(goal, true, GoalsEngine.PerformanceNatureEnum.Worst);
            }

            int nCount = 0;

            foreach (GoalInfo gOut in goalsAll)
            {
                float maxValue = 0;
                long  maxID    = 0;

                foreach (GoalInfo gIn in goalsAll)
                {
                    float contrDifference = gIn.ContributionMax - gIn.Contribution;

                    if (contrDifference > maxValue && !goalsPicked.Exists(i => i.ID == gIn.ID) && gIn.Status == DTC.StatusEnum.Running)
                    {
                        maxValue = contrDifference;
                        maxID    = gIn.ID;
                    }
                }

                if (maxID > 0 && !goalsPicked.Exists(i => i.ID == maxID))
                {
                    goalsPicked.Add(goalsAll.Find(i => i.ID == maxID));
                }

                nCount++;
                if (nCount >= numItems)
                {
                    break;
                }
            }

            return(goalsPicked);
        }
示例#6
0
        public IEnumerable <GoalInfo> Get(int rangeID, bool getPresentValues, int standartOrProjected)
        {
            List <GoalInfo> goals = new List <GoalInfo>();

            DTC.RangeEnum range = (DTC.RangeEnum)rangeID;

            OwnerInfo owner = DB.Owner.GetOwner(range, DateTime.Today);

            goals = DB.Goals.GetGoals(owner, true);
            DayInfo today = DB.Days.GetDay(DateTime.Today, true);

            foreach (GoalInfo goal in goals)
            {
                if (standartOrProjected == 1)
                {
                    goal.PresentPercentage = goal.GetPresentPercentage();
                    goal.DesiredValue      = goal.GoalValue;
                }
                if (standartOrProjected == 2)
                {
                    goal.PresentPercentage = goal.GetPerformance(false, today);     // What does it mean? isFull
                    goal.DesiredValue      = goal.GetDesiredValue(today);
                }
            }

            goals = goals.OrderByDescending(i => i.Status).OrderByDescending(i => i.PresentPercentage).ToList();

            if (getPresentValues)
            {
                List <GoalGroupInfo> goalGroups          = DB.Goals.GetGoalGroups();
                GoalsEngine          goalEngine          = new GoalsEngine(goals, goalGroups, today);
                GoalsEngine.PerformanceNatureEnum nature = GoalsEngine.PerformanceNatureEnum.Normal;
                if (standartOrProjected == 1)
                {
                    nature = GoalsEngine.PerformanceNatureEnum.Worst;
                }
                else if (standartOrProjected == 1)
                {
                    nature = GoalsEngine.PerformanceNatureEnum.Normal;
                }

                foreach (GoalInfo goal in goals)
                {
                    goal.Contribution    = goalEngine.GetGoalContributionWeighted(goal, false, nature);
                    goal.ContributionMax = goalEngine.GetGoalContributionWeighted(goal, true, nature);
                }
            }


            return(goals);
        }
示例#7
0
        public IEnumerable <NewsInfo> Get(DTC.RangeEnum range, int parameter, string strDateStart, string strDateEnd)
        {
            DateTime dtStart = DateTime.Today;
            DateTime dtEnd   = DateTime.Today;

            List <NewsInfo> events = new List <NewsInfo>();

            if (strDateStart != string.Empty)
            {
                dtStart = DTC.Date.GetDateFromString(strDateStart, DTC.Date.DateStyleEnum.Universal);
            }

            if (strDateEnd != string.Empty)
            {
                dtEnd = DTC.Date.GetDateFromString(strDateEnd, DTC.Date.DateStyleEnum.Universal);
            }

            if (parameter == 1)
            {
                if (range == DTC.RangeEnum.Day)
                {
                    events = DB.News.GetNews(dtStart, dtEnd);
                }
                else if (range == DTC.RangeEnum.Week)
                {
                    WeekInfo week = DB.Weeks.GetWeek(dtStart, false);
                    events = DB.News.GetNews(week.StartDate, week.EndDate);
                    events = events.OrderBy(i => i.Date).ToList();
                }
            }
            else if (parameter == 2)
            {
                if (range == DTC.RangeEnum.Day)
                {
                    events = DB.News.GetTheDayInHistory(dtStart);
                }
                else if (range == DTC.RangeEnum.Week)
                {
                    WeekInfo week = DB.Weeks.GetWeek(dtStart, false);
                    events = DB.News.GetNewsLastYear(week.StartDate, week.EndDate);
                }
            }

            return(events);
        }
示例#8
0
        public bool CheckIsThisTheLastDayOf(DTC.RangeEnum range)
        {
            bool result = false;

            if (range == DTC.RangeEnum.Week)
            {
                if (theDate.DayOfWeek == DayOfWeek.Sunday)
                {
                    result = true;
                }
            }
            else if (range == DTC.RangeEnum.Month)
            {
                if (theDate.AddDays(1).Day == 1)
                {
                    result = true;
                }
            }
            else if (range == DTC.RangeEnum.Quarter)
            {
                QuarterInfo thisQuarter    = new QuarterInfo(theDate);
                QuarterInfo anotherQuarter = new QuarterInfo(theDate.AddDays(1));

                if (thisQuarter.Quarter != anotherQuarter.Quarter)
                {
                    result = true;
                }
            }
            else if (range == DTC.RangeEnum.Year)
            {
                int thisYear = theDate.Year;

                if (theDate.AddDays(1).Year == thisYear + 1)
                {
                    result = true;
                }
            }

            return(result);
        }
示例#9
0
        public IEnumerable <ProjectInfo> Get(int rangeID, string projectParameter)
        {
            List <ProjectInfo> projects = new List <ProjectInfo>();

            DTC.RangeEnum   range = (DTC.RangeEnum)rangeID;
            OwnerInfo       owner = DB.Owner.GetOwner(range, DateTime.Today);
            List <GoalInfo> goals = DB.Goals.GetGoals(owner, true);
            DayInfo         today = DB.Days.GetDay(DateTime.Today, true);

            foreach (GoalInfo goal in goals)
            {
                if (goal.PrimaryProjectID > 0)
                {
                    ProjectInfo      project      = DB.Projects.GetProject(goal.PrimaryProjectID);
                    ProjectGroupInfo projectGroup = DB.ProjectGroups.GetProjectGroup(project.ProjectGroupID);
                    project.SmartCode = project.GetSmartCode(projectGroup, false);
                    projects.Add(project);
                }
            }

            return(projects);
        }
示例#10
0
        private PeriodInfo GetNextPrev(DTC.RangeEnum range, int p)
        {
            PeriodInfo period = new PeriodInfo(startDate, endDate);

            if (range == DTC.RangeEnum.Day)
            {
                period.StartDate = startDate.AddDays(1 * p);
                period.EndDate   = endDate.AddDays(1 * p);
            }
            else if (range == DTC.RangeEnum.Week)
            {
                period.StartDate = startDate.AddDays(7 * p);
                period.EndDate   = endDate.AddDays(7 * p);
            }
            else if (range == DTC.RangeEnum.Month)
            {
                period.StartDate = startDate.AddMonths(1 * p);
                period.EndDate   = endDate.AddMonths(1 * p);
            }
            else if (range == DTC.RangeEnum.Quarter)
            {
                period.StartDate = startDate.AddMonths(3 * p);
                period.EndDate   = endDate.AddMonths(3 * p);
            }
            else if (range == DTC.RangeEnum.Year)
            {
                period.StartDate = startDate.AddYears(1 * p);
                period.EndDate   = endDate.AddYears(1 * p);
            }
            else if (range == DTC.RangeEnum.Decade)
            {
                period.StartDate = startDate.AddYears(10 * p);
                period.EndDate   = endDate.AddYears(10 * p);
            }

            return(period);
        }
示例#11
0
 public PeriodInfo GetPrev(DTC.RangeEnum range)
 {
     return(GetNextPrev(range, -1));
 }
示例#12
0
            public static void GetNextPrevDates(DTC.RangeEnum range, DateTime date, NextPrevEnum np, out DateTime startDate, out DateTime endDate)
            {
                startDate = DateTime.Today;
                endDate   = DateTime.Today;

                if (range == DTC.RangeEnum.Day)
                {
                    if (np == NextPrevEnum.Next)
                    {
                        startDate = date.AddDays(1);
                        endDate   = startDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = date.AddDays(-1);
                        endDate   = startDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = date;
                        endDate   = startDate;
                    }
                }
                else if (range == DTC.RangeEnum.Week)
                {
                    WeekInfo week = new WeekInfo(date);

                    if (np == NextPrevEnum.Next)
                    {
                        startDate = GetNextWeek(week).StartDate;
                        endDate   = GetNextWeek(week).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = GetPreviousWeek(week).StartDate;
                        endDate   = GetPreviousWeek(week).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = week.StartDate;
                        endDate   = week.EndDate;
                    }
                }
                else if (range == DTC.RangeEnum.Month)
                {
                    MonthInfo month = new MonthInfo(date);

                    if (np == NextPrevEnum.Next)
                    {
                        startDate = GetNextMonth(month).StartDate;
                        endDate   = GetNextMonth(month).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = GetPreviousMonth(month).StartDate;
                        endDate   = GetPreviousMonth(month).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = month.StartDate;
                        endDate   = month.EndDate;
                    }
                }
                else if (range == DTC.RangeEnum.Quarter)
                {
                    QuarterInfo quarter = new QuarterInfo(date);

                    if (np == NextPrevEnum.Next)
                    {
                        startDate = GetNextQuarter(quarter).StartDate;
                        endDate   = GetNextQuarter(quarter).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = GetPreviousQuarter(quarter).StartDate;
                        endDate   = GetPreviousQuarter(quarter).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = quarter.StartDate;
                        endDate   = quarter.EndDate;
                    }
                }
                else if (range == DTC.RangeEnum.Year)
                {
                    if (np == NextPrevEnum.Next)
                    {
                        startDate = new YearInfo(date.Year + 1).StartDate;
                        endDate   = new YearInfo(date.Year + 1).EndDate;
                    }
                    if (np == NextPrevEnum.Previous)
                    {
                        startDate = new YearInfo(date.Year - 1).StartDate;
                        endDate   = new YearInfo(date.Year - 1).EndDate;
                    }
                    if (np == NextPrevEnum.Today)
                    {
                        startDate = new YearInfo(date.Year).StartDate;
                        endDate   = new YearInfo(date.Year).EndDate;
                    }
                }
            }