Ejemplo n.º 1
0
        public void Create(SprintModel sprint)
        {
            using (SQLiteCommand command = new SQLiteCommand(Connection))
            {
                sprint.CreateTime = DateTime.Now;

                command.CommandText = @"
INSERT INTO T_SPRINTS
    (jira_id, name, create_time, sprint_state_id)
VALUES
    (@jira_id, @name, @create_time, @sprint_state_id);
SELECT last_insert_rowid()
";
                command.Parameters.Add(new SQLiteParameter("@jira_id", sprint.JiraId));
                command.Parameters.Add(new SQLiteParameter("@name", sprint.Name));
                command.Parameters.Add(new SQLiteParameter("@create_time", sprint.CreateTime));
                command.Parameters.Add(new SQLiteParameter("@sprint_state_id", SprintState.Idle));

                try
                {
                    sprint.Id = Convert.ToInt32(command.ExecuteScalar());
                }
                catch
                {
                    throw new Exception($"Duplicate sprint name \"{sprint.Name}\"");
                }
            }
        }
Ejemplo n.º 2
0
        public ActionResult SaveSprint(AddEditSprintViewModel sprintViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("NewSprint", sprintViewModel));
            }

            SprintModel model = _dataManager.FindSprintById(sprintViewModel.Id);

            if (model == null)
            {
                SprintModel sprintModel = Mapper.Map <SprintModel>(sprintViewModel);

                _dataManager.AddSprint(sprintModel);
            }
            else
            {
                model.Name       = sprintViewModel.Name;
                model.TargetDate = sprintViewModel.TargetDate;
                _dataManager.UpdateSprint(model);
            }



            _dataManager.SaveChanges();

            return(RedirectToAction("ViewProject", "Projects", new { Id = sprintViewModel.ProjectId }));
        }
        //
        // GET: /Sprint/
        public ActionResult Index()
        {
            int productId  = Int32.Parse(Session["ProductId"].ToString());
            var sprintRepo = new SprintRepository();

            bool isSprintActive;
            var  tasks = sprintRepo.GetCurrentSprintTasks(productId, out isSprintActive);

            if (tasks == null)
            {
                return(View(new SprintModel {
                    IsSprintActive = false
                }));
            }

            var model = new SprintModel()
            {
                TodoItems          = tasks.Where(x => x.TaskStatus == DomainClasses.Enums.TaskStatus.Open).ToList(),
                InDevelopmentItems = tasks.Where(x => x.TaskStatus == DomainClasses.Enums.TaskStatus.Development).ToList(),
                InTestingItems     = tasks.Where(x => x.TaskStatus == DomainClasses.Enums.TaskStatus.Testing).ToList(),
                DoneItems          = tasks.Where(x => x.TaskStatus == DomainClasses.Enums.TaskStatus.Closed).ToList(),
                IsSprintActive     = isSprintActive
            };

            return(View(model));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Constructor to initialize data
        /// before initialize the view
        /// </summary>
        /// <param name="model"> Project model where backlog items are from</param>
        public SingleSprintView(SprintModel model)
        {
            InitializeComponent();

            // Check dataContext for certain view model
            if (!(DataContext is SingleSprintViewModel viewModel))
            {
                return;
            }

            // Set project slug to get the project
            viewModel.ProjectSlug = model.ProjectSlug;
            viewModel.SprintSlug  = model.SprintSlug;

            _project = new ProjectModel {
                ProjectSlug = model.ProjectSlug
            };
            _sprint = new SprintModel();
            _sprint = model;

            viewModel.GetSprintFromApi();
            viewModel.GetSprintBacklogItemsFromApi();
            viewModel.GetAllBacklogItemsFromApi();

            // Disable settings button if database installation failed
            if (Properties.Settings.Default.db_status == "NOK")
            {
                ProjectSettingsButton.IsEnabled = false;
            }


            Messenger.Default.Register <NotificationMessage>(this, NavigateToNewPageNotification);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create a new SprintModel object by parsing a CSV string.
        /// </summary>
        ///
        /// <param name="sprintData">A CSV containing data to set up the sprint.</param>
        /// <returns>A SprintModel object corresponding to the input string.</returns>

        private SprintModel createSprint(string sprintData)
        {
            SprintModel sm = new SprintModel();

            //This is a comma delimited list
            string[] parts = sprintData.Split(',');
            string[] small;

            //Completion date
            small = parts[5].Split('=');

            if (small[1] == "<null>")
            {
                sm.CompleteDate = Epoch;
            }
            else
            {
                sm.CompleteDate = DateTime.Parse(small[1]);
            }

            //End date
            small = parts[4].Split('=');

            if (small[1] == "<null>")
            {
                sm.EndDate = Epoch;
            }
            else
            {
                sm.EndDate = DateTime.Parse(small[1]);
            }

            //Name
            small   = parts[2].Split('=');
            sm.Name = small[1];

            //Start date
            small = parts[3].Split('=');

            if (small[1] == "<null>")
            {
                sm.StartDate = Epoch;
            }
            else
            {
                sm.StartDate = DateTime.Parse(small[1]);
            }

            //State
            small    = parts[1].Split('=');
            sm.State = small[1];

            //Tasks
            sm.Tasks = new List <TaskModel>();

            return(sm);
        }
Ejemplo n.º 6
0
        public ActionResult DeleteSprint(int sprintId)
        {
            SprintModel sprintModel = _dataManager.FindSprintById(sprintId);

            _dataManager.RemoveSprint(sprintModel.Id);

            _dataManager.SaveChanges();


            return(RedirectToAction("ViewProject", "Projects", new { Id = sprintModel.ProjectId }));
        }
Ejemplo n.º 7
0
        public ActionResult EditSprint(int sprintId)
        {
            SprintModel model = _dataManager.FindSprintById(sprintId);

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

            AddEditSprintViewModel viewModel = Mapper.Map <AddEditSprintViewModel>(model);

            return(PartialView("NewSprint", viewModel));
        }
Ejemplo n.º 8
0
        public void Delete(SprintModel sprint)
        {
            using (SQLiteCommand command = new SQLiteCommand(Connection))
            {
                command.CommandText = @"
UPDATE T_SPRINTS
SET
     sprint_state_id = @state_deleted
    ,update_time = CURRENT_TIMESTAMP
WHERE id = @id
";
                command.Parameters.Add(new SQLiteParameter("@id", sprint.Id));
                command.Parameters.Add(new SQLiteParameter("@state_deleted", SprintState.Deleted));
                command.ExecuteNonQuery();
            }
        }
        /// <summary>
        /// Handle create a sprint api call
        /// </summary>
        /// <param name="sprint"> Model of the new sprint</param>
        /// <returns> Boolean true if the api call was a success false if there where complications</returns>
        public bool CreateSprint(SprintModel sprint)
        {
            if (string.IsNullOrEmpty(sprint.Name) || string.IsNullOrEmpty(sprint.StartDate) || string.IsNullOrEmpty(sprint.EndDate))
            {
                MessageBox.Show("Don't leave the fields empty");
                return(false);
            }

            var response = Post <SprintModel>($"/api/v2/project/{sprint.ProjectSlug}/sprint", sprint);

            if (_responseHandler.CheckForErrorResponse(response))
            {
                return(true);
            }

            MessageBox.Show("Error when creating a sprint please try again!");
            return(false);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Add a task to a sprint. First, check if a given sprint already
        /// exists inside of the List<SprintModel> List. If a given sprint
        /// already exists, then add the task, otherwise create the sprint,
        /// then add the task.
        /// </summary>
        ///
        /// <param name="sprintData">The name of the sprint in which to add the task.</param>
        /// <param name="tm">The task to add to the sprint.</param>
        private void addToSprint(string sprintData, TaskModel tm)
        {
            string name = sprintData == null ? "Unassigned Tasks" : getSprintName(sprintData);

            //A new sprint may need to be created
            if (sprintData == null && !Sprints.ContainsKey(name))
            {
                Sprints[name] = new SprintModel();
                Sprints[name].CompleteDate = Epoch;
                Sprints[name].EndDate      = Epoch;
                Sprints[name].Name         = name;
                Sprints[name].StartDate    = Epoch;
                Sprints[name].State        = "FUTURE";
                Sprints[name].Tasks        = new List <TaskModel>();
            }
            else if (!Sprints.ContainsKey(name))
            {
                Sprints[name] = createSprint(sprintData);
            }

            Sprints[name].Tasks.Add(tm);
        }
Ejemplo n.º 11
0
        public ActionResult PrintSprintStatusReport(int sprintId)
        {
            SprintModel sprintModel = _dataManager.FindSprintById(sprintId);

            if (sprintModel == null)
            {
                HttpNotFound();
            }

            SprintStatusReportBuilder statusReportBuilder = new SprintStatusReportBuilder(_dataManager);
            var sprintReport = statusReportBuilder.BuildSprintStatus(sprintModel.Id);

            SprintStatusReportViewModel model = Mapper.Map <SprintStatusReportViewModel>(sprintReport);

            model.HideGenerate = true;

            var action = new Rotativa.ViewAsPdf("Reports/_partialSprintStatusReport", model: model)
            {
                FileName = "Sprint status report.pdf"
            };

            return(action);
        }
        /// <summary>
        /// SearchBox event handler
        /// </summary>
        /// <param name="sender"> Sender</param>
        /// <param name="e"> Text changed event arg</param>
        private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            var t      = (TextBox)sender;
            var filter = t.Text;
            var cv     = CollectionViewSource.GetDefaultView(SprintsGrid.ItemsSource);

            if (filter == "")
            {
                cv.Filter = null;
            }
            else
            {
                cv.Filter = o =>
                {
                    SprintModel item = o as SprintModel;
                    if (t.Name == "txtId")
                    {
                        return(item != null && (item.Id == Convert.ToInt32(filter)));
                    }
                    return(item != null && (item.Name.ToUpper().StartsWith(filter.ToUpper())));
                };
            }
        }
Ejemplo n.º 13
0
        public SprintStatusModel BuildSprintStatus(int sprintId)
        {
            SprintModel sprint = _dataManager.FindSprintById(sprintId);

            var taskDificultyLevels     = _dataManager.TaskDificultyLevels;
            var userList                = _dataManager.UserList;
            var tasklist                = _dataManager.TaskList.Where(task => task.SprintId == sprint.Id).ToList();
            int overallEffortEstimation = 0;
            int overallWorkEffort       = 0;
            List <TaskStatusModel> taskStatusModelList = new List <TaskStatusModel>();

            tasklist.ForEach(task =>
            {
                try
                {
                    TaskStatusModel model    = BuildTaskStatus(task, taskDificultyLevels, userList);
                    overallEffortEstimation += model.EffortEstimation;
                    overallWorkEffort       += model.WorkEffort;
                    taskStatusModelList.Add(model);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to calculate task status for task {0} {1} due to :{2}", task.Id, task.Name, e.Message);
                }
            });
            int totalNumberOfTasks    = taskStatusModelList.Count;
            int numberOfFinishedTasks = 0;

            taskStatusModelList.ForEach(task =>
            {
                if (task.Status.Equals(TaskState.Finished))
                {
                    numberOfFinishedTasks++;
                }
            });



            int percentageOfCompletion = 0;

            try
            {
                percentageOfCompletion = numberOfFinishedTasks * 100 / totalNumberOfTasks;
            }
            catch (Exception)
            {
                //Devided by zero exception
            }



            SprintStatusModel sprintStatusModel = new SprintStatusModel()
            {
                Id                      = sprint.Id,
                Name                    = sprint.Name,
                TargetDate              = sprint.TargetDate,
                PercentageOfCompletion  = percentageOfCompletion,
                OverallEffortEstimation = overallEffortEstimation,
                OverallWorkEffort       = overallWorkEffort,
                TaskStatusList          = taskStatusModelList
            };

            return(sprintStatusModel);
        }