Esempio n. 1
0
        internal static int AddDatesFromSchedule(
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			DataGridViewRow row,
			int startInd,
			int length,
			string user,
			string userMark)
        {
            int maxInd = row.Cells.Count - viewColumnsIndexes.FirstDateColumnIndex - 1;
            if (startInd > maxInd)
                return viewColumnsIndexes.FirstDateColumnIndex + maxInd + 1;
            int ind = 0;
            DateTime date = freeDaysCalculator.GetWorkDayFromCount(startInd);
            DateTime today = DateTime.Now.Date;
            while (length > 0)
            {
                var dayIndex =  (int) Math.Ceiling(date.Subtract(today).TotalDays);
                if (dayIndex > maxInd)
                    return viewColumnsIndexes.FirstDateColumnIndex + maxInd + 1;
                var cell = row.Cells[dayIndex + viewColumnsIndexes.FirstDateColumnIndex];
                DayType dt = freeDaysCalculator.GetDayType(date, user);
                if (dt == DayType.WorkDay)
                    cell.Value = userMark;
                cell.SetColorByDayType(dt);
                if (dt == DayType.WorkDay || dt == DayType.Vacations)
                    --length;

                ++ind;
                date = date.AddDays(1);
            }
            return startInd + ind;
        }
Esempio n. 2
0
        internal static int AddLeadTaskRow(
			DataGridView dgv,
			ViewFiltersBuilder viewFiltersBuilder,
			WorkItemInfoFiller workItemInfoFiller,
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			FocusFactorCalculator focusFactorCalculator,
			WorkItem leadTask,
			DataContainer data,
			Dictionary<int, string> planningAssignments)
        {
            dgv.Rows.Add(new DataGridViewRow());
            var leadTaskRow = dgv.Rows[dgv.Rows.Count - 1];

            List<int> blockersIds = data.BlockersDict.ContainsKey(leadTask.Id)
                ? data.BlockersDict[leadTask.Id]
                : null;
            bool shouldCheckEstimate = workItemInfoFiller.FillLeadTaskInfo(
                viewFiltersBuilder,
                leadTask,
                leadTaskRow,
                data,
                blockersIds);

            viewFiltersBuilder.MarkLeadTaskRow(leadTaskRow);

            if (blockersIds != null)
                foreach (int blockerId in blockersIds)
                {
                    AddBlockerRow(
                        dgv,
                        viewFiltersBuilder,
                        workItemInfoFiller,
                        data,
                        planningAssignments,
                        blockerId);
                }

            if (leadTask.IsProposed())
                return ScheduleFiller.AddDatesProposed(
                    viewColumnsIndexes,
                    freeDaysCalculator,
                    focusFactorCalculator,
                    leadTask,
                    leadTaskRow,
                    viewColumnsIndexes.FirstDateColumnIndex,
                    m_proposedLtMark,
                    m_proposedLtMark,
                    shouldCheckEstimate);
            return ScheduleFiller.AddDatesActive(
                viewColumnsIndexes,
                freeDaysCalculator,
                focusFactorCalculator,
                leadTask,
                leadTaskRow,
                viewColumnsIndexes.FirstDateColumnIndex,
                m_activeLtMark,
                m_activeLtMark);
        }
Esempio n. 3
0
        public MainForm()
        {
            InitializeComponent();

            m_config = ConfigManager.LoadConfig();

            m_focusFactorCalculator = new FocusFactorCalculator(m_config.FocusFactors);

            s_viewColumnsIndexes = new ViewColumnsIndexes(scheduleDataGridView);
            s_planColumnsIndexes = new ViewColumnsIndexes(planningDataGridView);
            ScheduleColumnsPresenter.InitColumns(
                scheduleDataGridView,
                s_viewColumnsIndexes.FirstDateColumnIndex,
                1);
            ScheduleColumnsPresenter.InitColumns(
                planningDataGridView,
                s_planColumnsIndexes.FirstDateColumnIndex,
                3);

            m_holidays = m_config.Holidays;
            s_freeDaysCalculator.SetHolidays(m_holidays);

            UpdateHolidays();

            if (m_config.Vacations.Count > 0)
            {
                vacationsButton.Enabled = true;
                var vacationsUsers = m_config.Vacations.Select(v => v.User).ToList();
                vacationsUsers.Sort();
                workersComboBox.DataSource = vacationsUsers;
                s_freeDaysCalculator.SetVacations(m_config.Vacations);
            }

            tfsUrlTextBox.Text = m_config.TfsUrl;
            s_stateContainer.ByArea = m_config.ByArea;
            if (m_config.WorkMode != WorkMode.Query)
            {
                s_stateContainer.WorkMode = m_config.WorkMode;
                InitFirst();
                queryTextBox.Text = Resources.QueryExample;
            }
            else
            {
                queryTextBox.Text = m_config.QueryPath;
                queryTextBox.ForeColor = Color.Black;
                ParamsGroupBox.Enabled = false;
                makeScheduleButton.Enabled = true;
            }

            m_viewMenuItems = new List<ToolStripMenuItem>
            {
                toggleIterationToolStripMenuItem,
                toggleSprintToolStripMenuItem,
                toggleDevCompletedToolStripMenuItem,
                toggleLTOnlyToolStripMenuItem,
                toggleBlockersToolStripMenuItem,
            };
        }
Esempio n. 4
0
        internal ViewFiltersApplier PresentData(
			DataContainer data,
			Dictionary<int, string> planningAssignments,
			List<string> allUsers,
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			FocusFactorCalculator focusFactorCalculator,
			DataGridView dgv)
        {
            var tasksSchedule = WorkItemsScheduler.MakeSchedule(
                data,
                planningAssignments,
                freeDaysCalculator,
                focusFactorCalculator);

            var alreadyAdded = new Dictionary<int, int>();
            var tasksByUser = new Dictionary<string, int>();

            var resultBuilder = new ViewFiltersBuilder(dgv, viewColumnsIndexes);
            var workItemInfoFiller = new WorkItemInfoFiller(dgv, viewColumnsIndexes);

            foreach (var leadTaskChildren in data.LeadTaskChildrenDict)
            {
                var leadTask = data.WiDict[leadTaskChildren.Key];

                int nextLtInd = RowsAdder.AddLeadTaskRow(
                    dgv,
                    resultBuilder,
                    workItemInfoFiller,
                    viewColumnsIndexes,
                    freeDaysCalculator,
                    focusFactorCalculator,
                    leadTask,
                    data,
                    planningAssignments);
                int ltRowInd = dgv.Rows.Count - 1;

                var childrenTasks = leadTaskChildren.Value
                    .Where(i => data.WiDict.ContainsKey(i))
                    .Select(i => data.WiDict[i])
                    .OrderBy(i => i.Priority() ?? 999)
                    .ToList();

                if (childrenTasks.Count > 0)
                {
                    int lastTaskInd = childrenTasks
                        .Select(task =>
                            RowsAdder.AddTaskRow(
                                dgv,
                                resultBuilder,
                                workItemInfoFiller,
                                viewColumnsIndexes,
                                freeDaysCalculator,
                                focusFactorCalculator,
                                task,
                                childrenTasks,
                                leadTask,
                                data,
                                planningAssignments,
                                allUsers,
                                alreadyAdded,
                                tasksByUser,
                                tasksSchedule))
                        .Max();
                    ScheduleFiller.ColorFdOutDays(
                        viewColumnsIndexes,
                        freeDaysCalculator,
                        dgv.Rows[ltRowInd],
                        nextLtInd,
                        lastTaskInd);
                }

                var notAccessableChildren = leadTaskChildren.Value
                    .Where(i => !data.WiDict.ContainsKey(i))
                    .ToList();
                foreach (int notAccessableChildId in notAccessableChildren)
                {
                    dgv.Rows.Add(new DataGridViewRow());
                    var taskRow = dgv.Rows[dgv.Rows.Count - 1];
                    workItemInfoFiller.FillNotAccessibleTaskInfo(viewColumnsIndexes, taskRow, notAccessableChildId);
                    resultBuilder.MarkTaskRow(taskRow);
                }
            }

            return resultBuilder.Build();
        }
Esempio n. 5
0
 internal void ToggleSprint(DataGridView dgv, ViewColumnsIndexes viewColumnsIndexes)
 {
     var column = dgv.Columns[viewColumnsIndexes.SprintColumnIndex];
     column.Visible = !column.Visible;
 }
Esempio n. 6
0
 internal void ToggleIteration(DataGridView dgv, ViewColumnsIndexes viewColumnsIndexes)
 {
     var column = dgv.Columns[viewColumnsIndexes.IterationColumnIndex];
     column.Visible = !column.Visible;
 }
 internal ViewFiltersBuilder(DataGridView dataGridView, ViewColumnsIndexes viewColumnsIndexes)
 {
     m_dataGridView = dataGridView;
     m_viewColumnsIndexes = viewColumnsIndexes;
 }
 internal WorkItemInfoFiller(DataGridView dataGridView, ViewColumnsIndexes viewColumnsIndexes)
 {
     m_dataGridView = dataGridView;
     m_viewColumnsIndexes = viewColumnsIndexes;
 }
        internal void FillNotAccessibleTaskInfo(
			ViewColumnsIndexes viewColumnsIndexes,
			DataGridViewRow taskRow,
			int notAccessableChildId)
        {
            taskRow.Cells[viewColumnsIndexes.TitleColumnIndex].Value = notAccessableChildId;
            taskRow.Cells[viewColumnsIndexes.AssignedToColumnIndex].Value = Resources.AccessDenied;
        }
Esempio n. 10
0
        private static int AddDates(
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			DataGridViewRow row,
			int startInd,
			int length,
			bool byDates,
			string user,
			string userMark)
        {
            int maxInd = row.Cells.Count - viewColumnsIndexes.FirstDateColumnIndex - 1;
            if (startInd - viewColumnsIndexes.FirstDateColumnIndex > maxInd)
                return viewColumnsIndexes.FirstDateColumnIndex + maxInd + 1;
            int ind = 0;
            while (length > 0)
            {
                int dateIndexShift = startInd - viewColumnsIndexes.FirstDateColumnIndex + ind;
                if (dateIndexShift > maxInd)
                    return viewColumnsIndexes.FirstDateColumnIndex + maxInd + 1;
                var cell = row.Cells[startInd + ind];
                ++ind;
                DateTime date = DateTime.Today.Date.AddDays(dateIndexShift);
                DayType dt = freeDaysCalculator.GetDayType(date, user);
                if (dt == DayType.WorkDay)
                    cell.Value = userMark;
                cell.SetColorByDayType(dt);
                if (byDates || dt == DayType.WorkDay || dt == DayType.Vacations)
                    --length;
            }
            return startInd + ind;
        }
Esempio n. 11
0
        internal static void ColorFdOutDays(
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			DataGridViewRow row,
			int startIndex,
			int finishIndex)
        {
            DateTime today = DateTime.Now.Date;
            for (int i = startIndex; i < finishIndex; i++)
            {
                DateTime date = today.AddDays(i - viewColumnsIndexes.FirstDateColumnIndex);
                if (freeDaysCalculator.GetDayType(date) != DayType.WorkDay)
                    continue;
                row.Cells[i].SetErrorColor();
                row.Cells[i].ToolTipText = Messages.ChildTaskHasLaterFd();
            }
        }
Esempio n. 12
0
        internal static int AddDatesActive(
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			FocusFactorCalculator focusFactorCalculator,
			WorkItem workItem,
			DataGridViewRow row,
			int startInd,
			string user,
			string userMark)
        {
            var taskStart = workItem.StartDate();
            var taskFinish = workItem.FinishDate();
            DateTime today = DateTime.Now.Date;
            if (taskFinish == null || taskFinish.Value.Date < today)
            {
                if (taskFinish != null)
                    row.Cells[viewColumnsIndexes.FirstDateColumnIndex - 1].Value = taskFinish.Value.ToString("dd.MM");

                var verificationResult = WorkItemVerifier.VerifyFinishDate(workItem);
                row.Cells[viewColumnsIndexes.FirstDateColumnIndex - 1].SetColorByVerification(verificationResult.Result);
                row.Cells[viewColumnsIndexes.FirstDateColumnIndex - 1].ToolTipText = verificationResult.AllMessagesString;

                double? remaining = workItem.Remaining();
                if (remaining != null)
                {
                    var length = focusFactorCalculator.CalculateDaysByTime(remaining.Value, user);
                    return AddDates(
                        viewColumnsIndexes,
                        freeDaysCalculator,
                        row,
                        startInd,
                        length,
                        false,
                        user,
                        userMark);
                }
            }
            else if (taskStart.HasValue)
            {
                int maxInd = row.Cells.Count - viewColumnsIndexes.FirstDateColumnIndex - 1;
                var indStart = (int)taskStart.Value.Date.Subtract(today).TotalDays;
                if (indStart < 0)
                    row.Cells[viewColumnsIndexes.FirstDateColumnIndex - 1].Value = taskStart.Value.ToString("dd.MM");
                indStart = Math.Min(Math.Max(1, indStart), maxInd) + viewColumnsIndexes.FirstDateColumnIndex;

                var indFinish = (int)taskFinish.Value.Date.Subtract(today).TotalDays;
                indFinish = Math.Min(Math.Max(1, indFinish), maxInd) + viewColumnsIndexes.FirstDateColumnIndex;

                AddDates(
                    viewColumnsIndexes,
                    freeDaysCalculator,
                    row,
                    indStart,
                    indFinish - indStart + 1,
                    true,
                    user,
                    userMark);

                return indFinish + 1;
            }
            return viewColumnsIndexes.FirstDateColumnIndex;
        }
Esempio n. 13
0
        internal static int AddDatesProposed(
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			FocusFactorCalculator focusFactorCalculator,
			WorkItem task,
			DataGridViewRow taskRow,
			int startInd,
			string user,
			string userMark,
			bool shouldCheckEstimate)
        {
            var verificationResult = WorkItemVerifier.VerifyEstimatePresence(task);
            if (verificationResult.Result != VerificationResult.Ok)
            {
                if (shouldCheckEstimate)
                {
                    var estimateCell = taskRow.Cells[viewColumnsIndexes.FirstDateColumnIndex - 1];
                    estimateCell.SetColorByVerification(verificationResult.Result);
                    estimateCell.ToolTipText = verificationResult.AllMessagesString;
                }
                return viewColumnsIndexes.FirstDateColumnIndex;
            }

            double? estimate = task.Estimate();

            var length = focusFactorCalculator.CalculateDaysByTime(estimate.Value, user);
            DateTime? finish = task.FinishDate();
            if (finish != null)
            {
                verificationResult = WorkItemVerifier.VerifyFinishDate(task);
                var estimateCell = taskRow.Cells[viewColumnsIndexes.FirstDateColumnIndex - 1];
                estimateCell.SetColorByVerification(verificationResult.Result);
                estimateCell.ToolTipText = verificationResult.AllMessagesString;
                estimateCell.Value = finish.Value.ToString("dd.MM");

                int finishShift = length - 1;
                DateTime startDate = finish.Value.Date;
                DateTime today = DateTime.Now.Date;
                while (finishShift > 0 && startDate >= today)
                {
                    startDate = startDate.AddDays(-1);
                    if (freeDaysCalculator.GetDayType(startDate, user) == DayType.WorkDay)
                        --finishShift;
                }
                if (finishShift == 0)
                {
                    var startShift = (int) startDate.Subtract(today).TotalDays;
                    startInd = Math.Max(startInd, startShift + viewColumnsIndexes.FirstDateColumnIndex);
                }
                else
                {
                    length -= finishShift;
                }
            }

            return AddDates(
                viewColumnsIndexes,
                freeDaysCalculator,
                taskRow,
                startInd,
                length,
                false,
                user,
                userMark);
        }
Esempio n. 14
0
        internal static int AddTaskRow(
			DataGridView dgv,
			ViewFiltersBuilder viewFiltersBuilder,
			WorkItemInfoFiller workItemInfoFiller,
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			FocusFactorCalculator focusFactorCalculator,
			WorkItem task,
			List<WorkItem> siblings,
			WorkItem leadTask,
			DataContainer data,
			Dictionary<int, string> planningAssignments,
			List<string> allUsers,
			Dictionary<int, int> alreadyAdded,
			Dictionary<string, int> tasksByUser,
			Dictionary<int, Tuple<int?, int>> tasksSchedule)
        {
            if (alreadyAdded.ContainsKey(task.Id))
                return viewColumnsIndexes.FirstDateColumnIndex;

            var nextInds = new List<int>();

            List<int> blockerIds = ProcessBlockers(
                dgv,
                viewFiltersBuilder,
                workItemInfoFiller,
                viewColumnsIndexes,
                freeDaysCalculator,
                focusFactorCalculator,
                data,
                planningAssignments,
                allUsers,
                task,
                siblings,
                leadTask,
                alreadyAdded,
                nextInds,
                tasksByUser,
                tasksSchedule);

            dgv.Rows.Add(new DataGridViewRow());
            var taskRow = dgv.Rows[dgv.Rows.Count - 1];

            workItemInfoFiller.FillTaskInfo(
                viewFiltersBuilder,
                task,
                siblings,
                leadTask,
                taskRow,
                data,
                planningAssignments,
                allUsers,
                blockerIds);

            viewFiltersBuilder.MarkTaskRow(taskRow);

            if (blockerIds != null)
                foreach (int blockerId in blockerIds)
                {
                    AddBlockerRow(
                        dgv,
                        viewFiltersBuilder,
                        workItemInfoFiller,
                        data,
                        planningAssignments,
                        blockerId);
                }

            if (task.IsResolved())
            {
                alreadyAdded.Add(task.Id, viewColumnsIndexes.FirstDateColumnIndex);
                return viewColumnsIndexes.FirstDateColumnIndex;
            }

            string assignedTo = planningAssignments.GetAssignee(task);
            if (!assignedTo.IsUnassigned() && tasksByUser.ContainsKey(assignedTo))
                nextInds.Add(tasksByUser[assignedTo]);

            int maxNextInd = viewColumnsIndexes.FirstDateColumnIndex;
            if (nextInds.Count > 0)
                maxNextInd = nextInds.Max();

            string userMark = GetUserMark(assignedTo);

            Tuple<int?, int> taskSchedule = null;
            int nextInd;

            if (tasksSchedule != null && tasksSchedule.ContainsKey(task.Id))
                taskSchedule = tasksSchedule[task.Id];

            if (taskSchedule != null && taskSchedule.Item1 != null)
            {
                nextInd = ScheduleFiller.AddDatesFromSchedule(
                    viewColumnsIndexes,
                    freeDaysCalculator,
                    taskRow,
                    taskSchedule.Item1.Value,
                    taskSchedule.Item2,
                    assignedTo,
                    userMark);
            }
            else
            {
                nextInd = task.IsProposed()
                    ? ScheduleFiller.AddDatesProposed(
                        viewColumnsIndexes,
                        freeDaysCalculator,
                        focusFactorCalculator,
                        task,
                        taskRow,
                        maxNextInd,
                        assignedTo,
                        userMark,
                        true)
                    : ScheduleFiller.AddDatesActive(
                        viewColumnsIndexes,
                        freeDaysCalculator,
                        focusFactorCalculator,
                        task,
                        taskRow,
                        maxNextInd,
                        assignedTo,
                        userMark);
            }
            alreadyAdded.Add(task.Id, nextInd);
            tasksByUser[assignedTo] = nextInd;
            return nextInd;
        }
Esempio n. 15
0
        private static List<int> ProcessBlockers(
			DataGridView dgv,
			ViewFiltersBuilder viewFiltersBuilder,
			WorkItemInfoFiller workItemInfoFiller,
			ViewColumnsIndexes viewColumnsIndexes,
			FreeDaysCalculator freeDaysCalculator,
			FocusFactorCalculator focusFactorCalculator,
			DataContainer data,
			Dictionary<int, string> planningAssignments,
			List<string> allUsers,
			WorkItem task,
			List<WorkItem> childrenTasks,
			WorkItem leadTask,
			Dictionary<int, int> alreadyAdded,
			List<int> nextInds,
			Dictionary<string, int> tasksByUser,
			Dictionary<int, Tuple<int?, int>> tasksSchedule)
        {
            if (!data.BlockersDict.ContainsKey(task.Id))
                return null;

            var blockerIds = data.BlockersDict[task.Id];
            var blokers = blockerIds
                .Where(b => data.WiDict.ContainsKey(b))
                .Select(b => data.WiDict[b])
                .OrderBy(b => b.Priority())
                .ToList();
            foreach (var blocker in blokers)
            {
                if (alreadyAdded.ContainsKey(blocker.Id))
                {
                    nextInds.Add(alreadyAdded[blocker.Id]);
                    continue;
                }

                var blockerSiblingTask = childrenTasks.FirstOrDefault(t => t.Id == blocker.Id);
                if (blockerSiblingTask != null)
                {
                    int blockerNextInd = AddTaskRow(
                        dgv,
                        viewFiltersBuilder,
                        workItemInfoFiller,
                        viewColumnsIndexes,
                        freeDaysCalculator,
                        focusFactorCalculator,
                        blockerSiblingTask,
                        childrenTasks,
                        leadTask,
                        data,
                        planningAssignments,
                        allUsers,
                        alreadyAdded,
                        tasksByUser,
                        tasksSchedule);
                    nextInds.Add(blockerNextInd);
                }
            }

            return blockerIds;
        }