Example #1
0
        private void AddTaskToPlanned(Todo boundItem)
        {
            KanbanPosition newPosition = new KanbanPosition();

            newPosition.TaskPid  = boundItem.pId;
            newPosition.Status   = Status.Planned;
            newPosition.Position = panelColumn1.Controls.Count;
            Sprint sprint = (Sprint)comboBoxCurrentSprint.SelectedItem;

            sprint.Kanban.Add(newPosition);
            HasChanges = true;

            TaskItem kanbanItem = new TaskItem();

            kanbanItem.Tag = newPosition;
            kanbanItem.DeleteButtonClicked += new DeleteButtonClickedEventHandler(kanbanItem_DeleteButtonClicked);
            panelColumn1.Controls.Add(kanbanItem);
            kanbanItem.Dock  = DockStyle.Top;
            kanbanItem.Width = panelColumn1.Width - 14;
            panelColumn1.Controls.SetChildIndex(kanbanItem, newPosition.Position);


            kanbanItem.Task   = boundItem;
            kanbanItem.Margin = new System.Windows.Forms.Padding(0, 0, 0, 2);
            SortableBindingList <Project> projects = (SortableBindingList <Project>)projectBindingSource.DataSource;
            var projectResult = from project in projects
                                where project.pId == kanbanItem.Task.ProjectPid
                                select project;

            if (projectResult.Count() > 0)
            {
                kanbanItem.Project = (Project)projectResult.First();
            }
        }
Example #2
0
        public List <Todo> ParseTasks(out string summary)
        {
            summary = string.Empty;
            int           lastPosition = spelledMultilineTextbox1.Textbox.SelectionStart;
            List <Todo>   result       = new List <Todo>();
            List <string> tasks        = new List <string>();
            string        task         = string.Empty;
            string        text         = spelledMultilineTextbox1.Textbox.Text;

            using (StringReader reader = new StringReader(text))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.Contains("--"))
                    {
                        if (task != string.Empty)
                        {
                            tasks.Add(task);
                            task = string.Empty;
                        }
                        task = string.Format("{0}{1}{2}", task, "\n", line).Replace("--", string.Empty);
                    }
                    else
                    {
                        task = string.Format("{0}{1}{2}", task, "\n", line);
                    }
                }
            }

            if (task != string.Empty)
            {
                tasks.Add(task);
                task = string.Empty;
            }
            spelledMultilineTextbox1.Textbox.Select(0, spelledMultilineTextbox1.Textbox.TextLength);
            spelledMultilineTextbox1.Textbox.SelectionColor = BlackTheme.ColorText;
            string projectsRegex = string.Empty;

            for (int i = 0; i < projectIdList.Count; i++)
            {
                string strKeyword = projectIdList[i];

                if (i == projectIdList.Count - 1)
                {
                    projectsRegex += "\\b" + strKeyword + "\\b";
                }
                else
                {
                    projectsRegex += "\\b" + strKeyword + "\\b|";
                }
            }

            string sptintsRegex = string.Empty;

            for (int i = 0; i < sprintIdList.Count; i++)
            {
                string strKeyword = sprintIdList[i];

                if (i == sprintIdList.Count - 1)
                {
                    sptintsRegex += "\\b" + strKeyword + "\\b";
                }
                else
                {
                    sptintsRegex += "\\b" + strKeyword + "\\b|";
                }
            }

            foreach (string newTask in tasks)
            {
                string text1            = newTask.Trim();
                string projectId        = string.Empty;
                string sprintId         = string.Empty;
                string shortDescription = string.Empty;
                string description      = string.Empty;
                string currentState     = string.Empty;
                Regex  regKeywords      = new Regex(projectsRegex, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                Match  regMatch;

                for (regMatch = regKeywords.Match(text1); regMatch.Success; regMatch = regMatch.NextMatch())
                {
                    // Process the words
                    int nStart  = regMatch.Index;
                    int nLenght = regMatch.Length;
                    projectId = text1.Substring(nStart, nLenght);
                    text1     = text1.Remove(nStart, nLenght);
                }
                Regex regKeywords2 = new Regex(sptintsRegex, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                for (regMatch = regKeywords2.Match(text1); regMatch.Success; regMatch = regMatch.NextMatch())
                {
                    // Process the words
                    int nStart  = regMatch.Index;
                    int nLenght = regMatch.Length;
                    sprintId = text1.Substring(nStart, nLenght);
                    text1    = text1.Remove(nStart, nLenght);
                }
                int firstBrake = text1.IndexOf("\n");
                if (firstBrake < 0)
                {
                    firstBrake = shortDescription.Trim().Length;
                }
                shortDescription = text1.Substring(0, firstBrake).Trim();

                description = text1.Trim().Remove(0, firstBrake).Trim();
                if (description.Contains("**"))
                {
                    int firstBrake2 = description.Trim().IndexOf("\n");
                    currentState = description.Substring(0, firstBrake2 + 1).Trim();
                    currentState = currentState.Replace("**", string.Empty).Trim();
                    description  = description.Substring((firstBrake2 + 1), description.Length - (firstBrake2 + 1)).Trim();
                }

                Todo todo = new Todo();
                todo.pId = Guid.NewGuid();
                todo.ShortDescription = shortDescription;
                todo.Description      = description;
                todo.CurrentState     = currentState;
                SortableBindingList <Project> projects = (SortableBindingList <Project>)projectBindingSource.DataSource;
                var     projects1 = from p in projects where p.Id == projectId.ToUpper() select p;
                Project project   = null;
                summary += string.Format("\r\n- {0}", todo.ShortDescription);
                if (projects1.Count() > 0)
                {
                    project         = (Project)projects1.First();
                    todo.ProjectPid = project.pId;
                    summary        += string.Format("[{0}{1}]", project.Id, project.ShortDescription);
                }

                SortableBindingList <Sprint> sprints = (SortableBindingList <Sprint>)sprintBindingSource.DataSource;
                var sprints1 = from s in sprints where s.Id == sprintId.ToUpper() select s;
                if (sprints1.Count() > 0)
                {
                    Sprint sprint        = (Sprint)sprints1.First();
                    int    lastPosition2 = 0;
                    foreach (KanbanPosition kanbanPosition in sprint.Kanban)
                    {
                        if (kanbanPosition.Status == Status.Todo)
                        {
                            if (kanbanPosition.Position > lastPosition2)
                            {
                                lastPosition2 = kanbanPosition.Position;
                            }
                        }
                    }
                    KanbanPosition newPosition = new KanbanPosition();
                    newPosition.TaskPid  = todo.pId;
                    newPosition.Position = lastPosition2 + 1;
                    newPosition.Status   = Status.Planned;
                    sprint.Kanban.Add(newPosition);
                    summary += string.Format(" - {0} {1} {2}", sprint.Id, sprint.ShortDescription, newPosition.Status);
                }
                result.Add(todo);
                summary += "\r\n";
            }
            spelledMultilineTextbox1.Textbox.SelectionStart = lastPosition;
            return(result);
        }
Example #3
0
        private void buttonAddTasks_Click(object sender, EventArgs e)
        {
            string parsedText = AddTasksEditor.Text;
            SortableBindingList <Todo> newTodos = new SortableBindingList <Todo>();

            sprintIdList = new List <string>();
            foreach (object obj in sprintBindingSource.List)
            {
                sprintIdList.Add(((Sprint)obj).Id);
            }
            projectIdList = new List <string>();
            foreach (object obj in projectBindingSource.List)
            {
                projectIdList.Add(((Project)obj).Id);
            }

            string projectsRegex = string.Empty;

            for (int i = 0; i < projectIdList.Count; i++)
            {
                string strKeyword = projectIdList[i];

                if (i == projectIdList.Count - 1)
                {
                    projectsRegex += "\\b" + strKeyword + "\\b";
                }
                else
                {
                    projectsRegex += "\\b" + strKeyword + "\\b|";
                }
            }

            string sptintsRegex = string.Empty;

            for (int i = 0; i < sprintIdList.Count; i++)
            {
                string strKeyword = sprintIdList[i];

                if (i == sprintIdList.Count - 1)
                {
                    sptintsRegex += "\\b" + strKeyword + "\\b";
                }
                else
                {
                    sptintsRegex += "\\b" + strKeyword + "\\b|";
                }
            }

            SortableBindingList <Project> projects = (SortableBindingList <Project>)projectBindingSource.DataSource;

            // generate id,s
            List <string> ids = new List <string>();

            foreach (Todo t in todoBindingSource.List)
            {
                ids.Add(t.Id);
            }
            ids.Sort();
            string lastId = ids.Last();
            int    count  = int.Parse(lastId.Split('-')[1]) + 1;

            try
            {
                Regex regexObj    = new Regex("//([^}]*).*{([^}]*)}");
                Match searchTasks = regexObj.Match(parsedText);
                while (searchTasks.Success)
                {
                    string taskProperties  = string.Empty;
                    string taskName        = string.Empty;
                    string taskDescription = string.Empty;
                    string step1           = string.Empty;

                    string searchProperties = searchTasks.Value;
                    try
                    {
                        Match result = Regex.Match(parsedText, "//.*");
                        taskProperties = result.Value.Replace("//", string.Empty).Trim();
                        step1          = searchTasks.Value.Remove(result.Index, result.Length);

                        try
                        {
                            Match searchTaskDescription = Regex.Match(step1, "{([^}]*)}");
                            taskName        = step1.Remove(searchTaskDescription.Index, searchTaskDescription.Length).Trim();
                            taskDescription = searchTaskDescription.Value.TrimStart('{').TrimEnd('}');
                            string[] descriptionItems = taskDescription.Split(new[] { "-----" }, StringSplitOptions.None);
                            string   istZustand       = string.Empty;
                            string   sollZustand      = string.Empty;
                            string   recherche        = string.Empty;
                            string   resultat         = string.Empty;
                            if (descriptionItems.Length >= 1)
                            {
                                List <string> words = new List <string>()
                                {
                                    "Ist Zustand:",
                                    "Ist:",
                                    "Soll Zustand:",
                                    "Recherche:",
                                    "Resultat:",
                                    "Soll:"
                                };
                                foreach (string item in descriptionItems)
                                {
                                    string found = string.Empty;
                                    words.ForEach(delegate(String word)
                                    {
                                        if (item.Contains(word))
                                        {
                                            found = word;
                                        }
                                    });
                                    switch (found)
                                    {
                                    case "Ist Zustand:":
                                        istZustand = item.Replace("Ist Zustand:", string.Empty).Trim();
                                        break;

                                    case "Ist:":
                                        istZustand = item.Replace("Ist:", string.Empty).Trim();
                                        break;

                                    case "Soll:":
                                        sollZustand = item.Replace("Soll:", string.Empty).Trim();
                                        break;

                                    case "Soll Zustand:":
                                        sollZustand = item.Replace("Soll Zustand:", string.Empty).Trim();
                                        break;

                                    case "Recherche:":
                                        recherche = item.Replace("Recherche:", string.Empty).Trim();
                                        break;

                                    case "Resultat:":
                                        resultat = item.Replace("Resultat:", string.Empty).Trim();
                                        break;

                                    default:
                                        sollZustand = descriptionItems[0].Trim();
                                        break;
                                    }
                                }
                            }

                            Todo newTodo = new Todo()
                            {
                                Id  = string.Format("{0}-{1}", lastId.Split('-')[0], count++),
                                pId = Guid.NewGuid(),
                                ShortDescription = taskName,
                                Description      = sollZustand,
                                CurrentState     = istZustand,
                                PublicText       = resultat,
                                Result           = recherche,
                            };
                            string projectId = string.Empty;
                            string sprintId  = string.Empty;

                            string text1            = taskProperties.Trim();
                            string shortDescription = string.Empty;
                            string description      = string.Empty;
                            string currentState     = string.Empty;
                            Regex  regKeywords      = new Regex(projectsRegex, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                            Match  regMatch;

                            for (regMatch = regKeywords.Match(text1); regMatch.Success; regMatch = regMatch.NextMatch())
                            {
                                // Process the words
                                int nStart  = regMatch.Index;
                                int nLenght = regMatch.Length;
                                projectId = text1.Substring(nStart, nLenght);
                                text1     = text1.Remove(nStart, nLenght);
                            }
                            Regex regKeywords2 = new Regex(sptintsRegex, RegexOptions.IgnoreCase | RegexOptions.Compiled);
                            for (regMatch = regKeywords2.Match(text1); regMatch.Success; regMatch = regMatch.NextMatch())
                            {
                                // Process the words
                                int nStart  = regMatch.Index;
                                int nLenght = regMatch.Length;
                                sprintId = text1.Substring(nStart, nLenght);
                                text1    = text1.Remove(nStart, nLenght);
                            }


                            var     projects1 = from p in projects where p.Id.ToLower() == projectId.ToLower() select p;
                            Project project   = null;
                            if (projects1.Count() > 0)
                            {
                                project            = (Project)projects1.First();
                                newTodo.ProjectPid = project.pId;
                            }
                            else
                            {
                                newTodo.ProjectPid = Guid.Empty;
                            }

                            SortableBindingList <Sprint> sprints = (SortableBindingList <Sprint>)sprintBindingSource.DataSource;
                            var sprints1 = from s in sprints where s.Id.ToLower() == sprintId.ToLower() select s;
                            if (sprints1.Count() > 0)
                            {
                                Sprint sprint        = (Sprint)sprints1.First();
                                int    lastPosition2 = 0;
                                foreach (KanbanPosition kanbanPosition in sprint.Kanban)
                                {
                                    if (kanbanPosition.Status == Status.Todo)
                                    {
                                        if (kanbanPosition.Position > lastPosition2)
                                        {
                                            lastPosition2 = kanbanPosition.Position;
                                        }
                                    }
                                }
                                KanbanPosition newPosition = new KanbanPosition();
                                newPosition.TaskPid  = newTodo.pId;
                                newPosition.Position = lastPosition2 + 1;
                                newPosition.Status   = Status.Planned;
                                sprint.Kanban.Add(newPosition);
                                newTodo.SprintPid = sprint.pId;
                                newTodos.Add(newTodo);
                            }
                            int ggg = 0;
                        }
                        catch (ArgumentException ex)
                        {
                            // Syntax error in the regular expression
                        }


                        int a = 0;
                    }
                    catch (ArgumentException ex)
                    {
                        // Syntax error in the regular expression
                    }
                    searchTasks = searchTasks.NextMatch();
                }

                ConfirmTasks confirmationForm = new ConfirmTasks();
                confirmationForm.SetBindingSources(projectBindingSource.DataSource, sprintBindingSource.DataSource, newTodos);
                if (confirmationForm.ShowDialog() == DialogResult.OK)
                {
                    foreach (Todo todo in confirmationForm.Todos)
                    {
                        todoBindingSource.Add(todo);
                    }
                }
            }
            catch (ArgumentException ex)
            {
                // Syntax error in the regular expression
            }
        }