Exemplo n.º 1
0
        private void ProcessData()
        {
            s_stateContainer.LastTfsUrl = tfsUrlTextBox.Text;

            try
            {
                List<WorkItem> leadTasks = GetLeadTasks();

                m_lastProcessedData = s_dataFiller.ProcessLeadTasks(
                    s_stateContainer.LastTfsUrl,
                    leadTasks,
                    ReportProgress);
            }
            catch (Exception exc)
            {
                HandleException(exc, Resources.LeadTasksParsingError);
                Invoke(
                    new Action(() =>
                    {
                        makeScheduleButton.Enabled = true;
                        loadLeadTasksButton.Enabled = true;
                        queryTextBox.Enabled = true;
                        percentLabel.Visible = false;
                    }));
                return;
            }

            Invoke(new Action(() =>
                {
                    try
                    {
                        m_viewFiltersApplier = s_dataPresenter.PresentData(
                            m_lastProcessedData,
                            null,
                            null,
                            s_viewColumnsIndexes,
                            s_freeDaysCalculator,
                            m_focusFactorCalculator,
                            scheduleDataGridView);
                    }
                    catch (Exception exc)
                    {
                        HandleException(exc, Resources.LeadTasksParsingError);
                        Invoke(new Action(() =>
                        {
                            makeScheduleButton.Enabled = true;
                            loadLeadTasksButton.Enabled = true;
                            queryTextBox.Enabled = true;
                        }));
                        return;
                    }
                    workersComboBox.DataSource = m_viewFiltersApplier.Users.Where(u => !u.IsUnassigned()).ToList();
                    vacationsButton.Enabled = m_viewFiltersApplier.Users.Count > 0;
                    var users = new List<string>(m_viewFiltersApplier.Users);
                    users.Insert(0, string.Empty);
                    usersFilterСomboBox.DataSource = users;
                    usersFilterСomboBox.Enabled = true;
                    usersLabel.Enabled = true;
                    var sprints = new List<string>(m_viewFiltersApplier.Sprints);
                    sprints.Insert(0, string.Empty);
                    sprintFilterComboBox.DataSource = sprints;
                    sprintFilterComboBox.Enabled = true;
                    sprintLabel.Enabled = true;
                    makeScheduleButton.Enabled = true;
                    loadLeadTasksButton.Enabled = true;
                    holidaysButton.Enabled = true;
                    queryTextBox.Enabled = true;
                    refreshButton.Enabled = true;
                    planButton.Enabled = true;
                    percentLabel.Visible = false;
                    mainTabControl.SelectTab(dataTabPage);
                }));
        }
Exemplo n.º 2
0
        private void RefreshData()
        {
            string currentUser = null;
            string currentSprint = null;
            Invoke(new Action(() =>
                {
                    loadLeadTasksButton.Enabled = false;
                    makeScheduleButton.Enabled = false;
                    refreshButton.Enabled = false;
                    if (usersFilterСomboBox.SelectedItem != null)
                        currentUser = usersFilterСomboBox.SelectedItem.ToString();
                    if (sprintFilterComboBox.SelectedItem != null)
                        currentSprint = sprintFilterComboBox.SelectedItem.ToString();
                    usersLabel.Enabled = false;
                    usersFilterСomboBox.Enabled = false;
                    scheduleDataGridView.Rows.Clear();

                    Text = GetFirstShortName();
                }));
            try
            {
                var leadTasksCollection = GetLastLeadTasks();

                var leadTasks = new List<WorkItem>(leadTasksCollection.Count);
                var oldSecond = s_stateContainer.WorkMode == WorkMode.AreaFirst ? m_config.LastIterationPaths : m_config.LastAreaPaths;
                var newSecond = new List<string>();
                foreach (WorkItem leadTask in leadTasksCollection)
                {
                    if (s_stateContainer.WorkMode != WorkMode.Query)
                    {
                        string second = s_stateContainer.GetParamForSecond(leadTask);
                        if (!oldSecond.Contains(second) && !newSecond.Contains(second))
                            newSecond.Add(second);
                        if (!s_stateContainer.IsSecondFromStateContains(second))
                            continue;
                    }
                    leadTasks.Add(leadTask);
                }
                m_lastProcessedData = s_dataFiller.ProcessLeadTasks(
                    tfsUrlTextBox.Text,
                    leadTasks,
                    ReportProgress);

                Invoke(new Action(() =>
                {
                    bool isDateChanged = scheduleDataGridView.Columns[s_viewColumnsIndexes.FirstDateColumnIndex].HeaderText != DateTime.Now.ToString("dd.MM");
                    if (isDateChanged)
                        ScheduleColumnsPresenter.InitColumns(
                            scheduleDataGridView,
                            s_viewColumnsIndexes.FirstDateColumnIndex,
                            1);
                    m_viewFiltersApplier = s_dataPresenter.PresentData(
                        m_lastProcessedData,
                        null,
                        null,
                        s_viewColumnsIndexes,
                        s_freeDaysCalculator,
                        m_focusFactorCalculator,
                        scheduleDataGridView);
                    workersComboBox.DataSource = m_viewFiltersApplier.Users;
                    vacationsButton.Enabled = m_viewFiltersApplier.Users.Count > 0;
                    var users2 = new List<string>(m_viewFiltersApplier.Users);
                    users2.Insert(0, string.Empty);
                    usersFilterСomboBox.DataSource = users2;

                    if (!string.IsNullOrEmpty(currentUser) && m_viewFiltersApplier.Users.Contains(currentUser))
                    {
                        usersFilterСomboBox.SelectedItem = currentUser;
                        m_viewFiltersApplier.FilterDataByUser(currentUser);
                    }

                    if (!string.IsNullOrEmpty(currentSprint) && m_viewFiltersApplier.Sprints.Contains(currentSprint))
                    {
                        sprintFilterComboBox.SelectedItem = currentSprint;
                        m_viewFiltersApplier.FilterDataBySprint(currentSprint);
                    }

                    usersFilterСomboBox.Enabled = true;
                    usersLabel.Enabled = true;
                    makeScheduleButton.Enabled = true;
                    loadLeadTasksButton.Enabled = true;
                    refreshButton.Enabled = true;
                    if (newSecond.Count > 0)
                    {
                        refreshButton.BackColor = Color.Yellow;
                        secondToolTip.SetToolTip(refreshButton,
                            Resources.NewItems + Environment.NewLine + string.Join(Environment.NewLine, newSecond));
                    }
                }));
            }
            catch (Exception exc)
            {
                HandleException(exc, Resources.LeadTasksParsingError);
                Invoke(
                    new Action(() =>
                    {
                        makeScheduleButton.Enabled = true;
                        loadLeadTasksButton.Enabled = true;
                        refreshButton.Enabled = true;
                    }));
            }
        }
Exemplo n.º 3
0
        private void MakePlan()
        {
            var planningAssignments = GetPlanningAssignments();

            var allUsers = usersFilterСomboBox.Items.Cast<string>().Where(i => !string.IsNullOrEmpty(i)).ToList();
            if (planningAssignments != null)
            {
                allUsers.AddRange(
                    planningAssignments.Values
                        .Distinct()
                        .Where(i => !allUsers.Contains(i)));
                allUsers.Sort();
            }

            string currentUser = null;
            Invoke(new Action(() =>
            {
                planButton.Enabled = false;
                if (usersFilterComboBox2.SelectedItem != null)
                    currentUser = usersFilterComboBox2.SelectedItem.ToString();
                usersLabel2.Enabled = false;
                usersFilterComboBox2.Enabled = false;
                planningDataGridView.Rows.Clear();
            }));
            try
            {
                Invoke(new Action(() =>
                {
                    bool isDateChanged = planningDataGridView.Columns[s_viewColumnsIndexes.FirstDateColumnIndex].HeaderText != DateTime.Now.ToString("dd.MM");
                    if (isDateChanged)
                        ScheduleColumnsPresenter.InitColumns(
                            planningDataGridView,
                            s_planColumnsIndexes.FirstDateColumnIndex,
                            3);

                    var comboBoxColumn = planningDataGridView.Columns[s_planColumnsIndexes.AssignedToColumnIndex] as DataGridViewComboBoxColumn;
                    comboBoxColumn.DataSource = allUsers;
                    m_planFiltersApplier = s_dataPresenter.PresentData(
                        m_lastProcessedData,
                        planningAssignments,
                        allUsers,
                        s_viewColumnsIndexes,
                        s_freeDaysCalculator,
                        m_focusFactorCalculator,
                        planningDataGridView);

                    workersComboBox.DataSource = m_planFiltersApplier.Users;
                    vacationsButton.Enabled = m_planFiltersApplier.Users.Count > 0;

                    var users2 = new List<string>(m_planFiltersApplier.Users);
                    users2.Insert(0, string.Empty);
                    usersFilterComboBox2.DataSource = users2;

                    if (!string.IsNullOrEmpty(currentUser) && m_planFiltersApplier.Users.Contains(currentUser))
                    {
                        usersFilterComboBox2.SelectedItem = currentUser;
                        m_planFiltersApplier.FilterDataByUser(currentUser);
                    }

                    usersFilterComboBox2.Enabled = true;
                    usersLabel2.Enabled = true;
                    planButton.Enabled = true;
                    autoplanButton.Enabled = true;
                }));
            }
            catch (Exception exc)
            {
                HandleException(exc, Resources.LeadTasksParsingError);
                Invoke(new Action(() => { planButton.Enabled = true; }));
            }
        }