Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(comboBox1.SelectedItem.ToString()) || string.IsNullOrEmpty(textBox2.Text) || string.IsNullOrEmpty(textBox3.Text) || string.IsNullOrEmpty(textBox4.Text) || string.IsNullOrEmpty(textBox5.Text) || string.IsNullOrEmpty(textBox1.Text) || string.IsNullOrEmpty(textBox6.Text) || string.IsNullOrEmpty(textBox7.Text))
            {
                MessageBox.Show("You must add all project information");
            }
            else if (string.IsNullOrEmpty(fastColoredTextBox1.Text))
            {
                MessageBox.Show("Code field cann't be null");
            }
            else
            {
                //bug
                BugViewModel bug = new BugViewModel
                {
                    ProjectName  = comboBox1.SelectedItem.ToString(),
                    ClassName    = textBox2.Text,
                    MethodName   = textBox3.Text,
                    StartLine    = Convert.ToInt16(textBox4.Text),
                    EndLine      = Convert.ToInt16(textBox5.Text),
                    ProgrammerId = Login.userId,
                    Status       = "0"
                };

                try
                {
                    BugDAO bugDao = new BugDAO();
                    bugDao.Insert(bug);
                    inserted = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                //image

                if (!string.IsNullOrEmpty(imageName))
                {
                    string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\code_image\";
                    Bug_Tracker.Model.PictureViewModel image = new Bug_Tracker.Model.PictureViewModel
                    {
                        ImagePath = "code_image",
                        ImageName = imageName,
                        BugId     = bug.BugId
                    };

                    try
                    {
                        ImageDAO codeDao = new ImageDAO();
                        codeDao.Insert(image);

                        File.Copy(imageName, appPath + ImageName);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    ////code
                    string c            = fastColoredTextBox1.Text;
                    string codeFileName = DateTime.Now.Second.ToString();

                    CodeViewModel code = new CodeViewModel
                    {
                        CodeFilePath        = "code",
                        CodeFileName        = codeFileName,
                        ProgrammingLanguage = programminLanguage,
                        BugId = bug.BugId
                    };

                    try
                    {
                        CodeDAO codeDao = new CodeDAO();
                        codeDao.Insert(code);

                        string path = "code/" + codeFileName + ".txt";
                        if (!File.Exists(path))
                        {
                            // Create a file to write to.
                            using (StreamWriter sw = File.CreateText(path))
                            {
                                sw.WriteLine(c);
                            }
                        }

                        inserted2 = true;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    ////Link

                    VersionControl sourceControl = new VersionControl
                    {
                        Link      = textBox1.Text,
                        StartLine = Convert.ToInt32(textBox6.Text),
                        EndLine   = Convert.ToInt32(textBox7.Text),
                        BugId     = bug.BugId
                    };

                    VersionControlDAO sourceControlDAO = new VersionControlDAO();

                    try
                    {
                        sourceControlDAO.Insert(sourceControl);
                        inserted3 = true;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    MessageBox.Show("Added");
                }
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            //bug
            BugViewModel bug = new BugViewModel
            {
                ProjectName  = textBox1.Text,
                ClassName    = textBox2.Text,
                MethodName   = textBox3.Text,
                StartLine    = Convert.ToInt16(textBox4.Text),
                EndLine      = Convert.ToInt16(textBox5.Text),
                ProgrammerId = Login.userId
            };

            try
            {
                BugDAO bugDao = new BugDAO();
                bugDao.Insert(bug);
            } catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //image


            string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\code_image\";

            Bug_Tracker.Model.PictureViewModel image = new Bug_Tracker.Model.PictureViewModel
            {
                ImagePath = "code_image",
                ImageName = imageName,
                BugId     = bug.BugId
            };

            try
            {
                ImageDAO codeDao = new ImageDAO();
                codeDao.Insert(image);

                File.Copy(imageName, appPath + ImageName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////code
            string c            = fastColoredTextBox1.Text;
            string codeFileName = DateTime.Now.Second.ToString();

            CodeViewModel code = new CodeViewModel
            {
                CodeFilePath        = "code",
                CodeFileName        = codeFileName,
                ProgrammingLanguage = programminLanguage,
                BugId = bug.BugId
            };

            try
            {
                CodeDAO codeDao = new CodeDAO();
                codeDao.Insert(code);

                string path = "code/" + codeFileName + ".txt";
                if (!File.Exists(path))
                {
                    // Create a file to write to.
                    using (StreamWriter sw = File.CreateText(path))
                    {
                        sw.WriteLine(c);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }


            //Bug bug = new Bug { BugId = }
        }
Esempio n. 3
0
        private void updatebtn_Click(object sender, EventArgs e)
        {
            //bug
            BugViewModel bug = new BugViewModel
            {
                BugId        = bugId,
                ProjectName  = label1.Text,
                ClassName    = textBox2.Text,
                MethodName   = textBox3.Text,
                StartLine    = Convert.ToInt16(textBox4.Text),
                EndLine      = Convert.ToInt16(textBox5.Text),
                ProgrammerId = Login.userId,
                Status       = "0"
            };

            try
            {
                BugDAO bugDao = new BugDAO();
                bugDao.Update(bug);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //image


            if (!string.IsNullOrEmpty(ImageName))
            {
                string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\code_image\";
                Bug_Tracker.Model.PictureViewModel image = new Bug_Tracker.Model.PictureViewModel
                {
                    ImageId   = imageId,
                    ImagePath = "code_image",
                    ImageName = ImageName,
                    BugId     = bug.BugId
                };

                try
                {
                    ImageDAO codeDao = new ImageDAO();
                    codeDao.Update(image);

                    File.Delete("code_image/" + currentImageName);
                    File.Copy(imageName, appPath + ImageName);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            ////code
            string c = fastColoredTextBox1.Text;

            //Code code = new Code
            //{
            //    CodeId = codeId,
            //    CodeFilePath = "code",
            //    CodeFileName = codeFileName,
            //    ProgrammingLanguage = programminLanguage,
            //    BugId = bug.BugId
            //};

            try
            {
                string path = @"code/" + codeFileName + ".txt";
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.WriteLine(c);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            MessageBox.Show("Updated");
        }