Exemplo n.º 1
0
        public IEnumerable <Story> GetStoriesByBacklogId(uint backlogId)
        {
            List <Story> stories = new List <Story>();

            try
            {
                using (MySqlConnection connection = OpenNewConnection())
                {
                    MySqlCommand selectCommand = CreateSelectAllCommand(_STORIES_TABLE_NAME, "BacklogId", "=", backlogId);
                    selectCommand.Connection = connection;

                    MySqlDataReader reader = selectCommand.ExecuteReader();

                    try
                    {
                        while (reader.Read())
                        {
                            uint   id              = SafeValueReader.GetUIntSafe(reader, "Id");
                            string name            = SafeValueReader.GetStringSafe(reader, "Name");
                            uint   importance      = SafeValueReader.GetUIntSafe(reader, "Importance");
                            uint   initialEstimate = SafeValueReader.GetUIntSafe(reader, "InitialEstimate");
                            string howToDemo       = SafeValueReader.GetStringSafe(reader, "HowToDemo");
                            string notes           = SafeValueReader.GetStringSafe(reader, "Notes");
                            string status          = _storyStatusesDataModel.GetStatus(Convert.ToUInt32(reader["Status"]));
                            uint   executorId      = SafeValueReader.GetUIntSafe(reader, "ExecutorId");

                            stories.Add(new Story(id, name, importance, initialEstimate, howToDemo, notes, status, executorId, backlogId));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger?.Error(ex);
                        throw;
                    }
                }
            }
            catch
            {
                throw;
            }

            return(stories);
        }
        public Sprint GetSprintByProjectId(uint projectId)
        {
            Sprint sprint = null;

            try
            {
                using (MySqlConnection connection = OpenNewConnection())
                {
                    MySqlCommand command = new MySqlCommand();
                    command.CommandText = $"SELECT * FROM `{_SPRINT_TABLE_NAME}` WHERE NOW() >= StartDate AND NOW() <= FinishDate AND ProjectId = {projectId} AND FinishedBeforeTheApointedDate = FALSE;";
                    command.Connection  = connection;

                    MySqlDataReader reader = command.ExecuteReader();

                    try
                    {
                        if (reader.Read())
                        {
                            uint     id         = SafeValueReader.GetUIntSafe(reader, "Id");
                            string   mainGoal   = SafeValueReader.GetStringSafe(reader, "MainGoal");
                            DateTime startDate  = reader.GetDateTime("StartDate");
                            DateTime finishDate = reader.GetDateTime("FinishDate");
                            uint     backlogId  = SafeValueReader.GetUIntSafe(reader, "BacklogId");
                            bool     finishedBeforeTheApointedDate = Convert.ToBoolean(reader["FinishedBeforeTheApointedDate"]);

                            sprint = new Sprint(id, mainGoal, startDate, finishDate, projectId, backlogId, finishedBeforeTheApointedDate);
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger?.Error(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger?.Fatal($"{GetType().Name}.GetTeamById(uint id) error.");
                _logger?.Fatal(ex);
            }

            return(sprint);
        }
        public IEnumerable <Sprint> GetAllProjectSprints(uint projectId)
        {
            List <Sprint> sprints = new List <Sprint>();

            try
            {
                using (MySqlConnection connection = OpenNewConnection())
                {
                    MySqlCommand command = CreateSelectAllCommand(_SPRINT_TABLE_NAME, "ProjectId", "=", projectId);
                    command.Connection = connection;

                    MySqlDataReader reader = command.ExecuteReader();

                    try
                    {
                        while (reader.Read())
                        {
                            uint     id         = SafeValueReader.GetUIntSafe(reader, "Id");
                            string   mainGoal   = SafeValueReader.GetStringSafe(reader, "MainGoal");
                            DateTime startDate  = reader.GetDateTime("StartDate");
                            DateTime finishDate = reader.GetDateTime("FinishDate");
                            uint     backlogId  = SafeValueReader.GetUIntSafe(reader, "BacklogId");
                            bool     finishedBeforeTheApointedDate = Convert.ToBoolean(reader["FinishedBeforeTheApointedDate"]);

                            sprints.Add(new Sprint(id, mainGoal, startDate, finishDate, projectId, backlogId, finishedBeforeTheApointedDate));
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger?.Error(ex);
                    }
                }
            }
            catch (Exception ex)
            {
                _logger?.Fatal($"{GetType().Name}.GetAllProjectSprints(uint projectId) error.");
                _logger?.Fatal(ex);
            }

            return(sprints);
        }
Exemplo n.º 4
0
        private void InitializeStatuses()
        {
            _statuses = new List <Status>();

            try
            {
                using (MySqlConnection connection = OpenNewConnection())
                {
                    MySqlCommand selectCommand = CreateSelectAllCommand(_STORY_STATUSES_TABLE_NAME);
                    selectCommand.Connection = connection;

                    MySqlDataReader reader = selectCommand.ExecuteReader();

                    try
                    {
                        while (reader.Read())
                        {
                            uint        id        = SafeValueReader.GetUIntSafe(reader, "Id");
                            string      name      = SafeValueReader.GetStringSafe(reader, "Name");
                            StoryStatus enumValue = GetStatusEnumValue(name);

                            _statuses.Add(new Status
                            {
                                Id        = id,
                                Name      = name,
                                EnumValue = enumValue
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        _logger?.Error(ex);
                        throw;
                    }
                }
            }
            catch
            {
                throw;
            }
        }