Ejemplo 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
                Bug bug = new Bug
                {
                    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.Image image = new Bug_Tracker.Model.Image
                    {
                        ImagePath = "code_image",
                        ImageName = ImageName,
                        BugId     = bug.BugId
                    };

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

                        File.Copy(imageName, appPath + ImageName);

                        inserted1 = true;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }

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

                Code code = new Code
                {
                    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

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

                SourceControlDAO sourceControlDAO = new SourceControlDAO();

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


                if (inserted && inserted1 && inserted2)
                {
                    MessageBox.Show("Added");
                }
                else
                {
                    MessageBox.Show("Unable to add");
                }
            }
        }
Ejemplo 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 = }
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            String class_name  = txt_class.Text;
            String method      = txt_method.Text;
            String line        = txt_line.Text;
            int    linee       = int.Parse(line);
            String path        = txt_path.Text;
            String symptom     = txt_sym.Text;
            String cause       = txt_cause.Text;
            String img_desc    = txt_name.Text;
            String code_block  = FastColour.Text;
            String source_link = txt_link.Text;

            if (String.IsNullOrEmpty(class_name))
            {
                MessageBox.Show("Please Provide Valid Information");
            }
            else if (String.IsNullOrEmpty(method))
            {
                MessageBox.Show("Please Provide Valid mathod name");
            }
            else if (String.IsNullOrEmpty(symptom))
            {
                MessageBox.Show("Please Provide Valid Symptom");
            }
            else if (String.IsNullOrEmpty(cause))
            {
                MessageBox.Show("Please Provide Valid Cause");
            }
            else if (String.IsNullOrEmpty(path))
            {
                MessageBox.Show("Please Provide Valid Path");
            }
            else if (String.IsNullOrEmpty(img_desc))
            {
                MessageBox.Show("Please Provide Valid Image Description");
            }
            else if (program_id == 0)
            {
                MessageBox.Show("Please Select program from Table");
            }
            else if (String.IsNullOrEmpty(source_link))
            {
                MessageBox.Show("Please Provide Valid Source Link");
            }
            else if (String.IsNullOrEmpty(code_block))
            {
                MessageBox.Show("Please Provide Error Code");
            }

            else
            {
                Bug bug = new Bug()
                {
                    program     = program_id,
                    class_name  = class_name,
                    method_name = method,
                    line_number = linee,
                    found_by    = id
                };
                BugDAO bu = new BugDAO();
                bug_id = bu.Insert(bug);
                Console.WriteLine(bug_id);

                BugDetails bugd = new BugDetails()
                {
                    bug_id      = bug_id,
                    image       = imgdata,
                    symptom     = symptom,
                    cause       = cause,
                    image_name  = img_desc,
                    code_block  = code_block,
                    source_link = source_link
                };
                BugDetailsDAO db = new BugDetailsDAO();

                int done = db.Insert(bugd);
                if (done != 0 && bug_id != 0)
                {
                    MessageBox.Show("inserted");
                    ClearFields();
                }
            }
        }