Ejemplo n.º 1
0
        // Ticket info
        private void button13_Click(object sender, EventArgs e)
        {
            string username    = "";
            string id          = "";
            string title       = "";
            string description = "";
            string date        = "";

            if (TicketSelected())
            {
                id          = (string)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["Id"].Value;
                username    = (string)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["username"].Value;
                title       = (string)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["title"].Value;
                description = (string)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["description"].Value;
                date        = (string)dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex].Cells["date"].Value;
            }
            else
            {
                CustomOkMessageBox b = new CustomOkMessageBox("Please select a ticket by its ID!");
                b.Show();
                return;
            }

            TicketInfo box = new TicketInfo(id, username, date, title, description);

            box.Show();
        }
Ejemplo n.º 2
0
        // self-assign
        private void button6_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 1)
            {
                CustomOkMessageBox box = new CustomOkMessageBox("It's better if you assign only one ticket at time!");
                box.Show();
                return;
            }

            int             selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow      = dataGridView1.Rows[selectedrowindex];
            string          id  = Convert.ToString(selectedRow.Cells["Id"].Value);
            string          num = Convert.ToString(selectedRow.Cells["status"].Value);



            Console.WriteLine(num);

            if (!num.Equals(TicketStatus.Unassigned.ToString()))
            {
                CustomOkMessageBox box = new CustomOkMessageBox("Ticket is not available to self assign");
                box.Show();
                return;
            }

            proxy.AssignSolver(username, id);
        }
Ejemplo n.º 3
0
        public void sendMail()
        {
            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.sapo.pt");

                mail.From = new MailAddress(origin);
                mail.To.Add(this.to);
                mail.Subject = subject + id;
                mail.Body    = "Recently you submitted the following ticket: \n\n"
                               +
                               this.title + '\n'
                               +
                               this.description + "\n\n"
                               +
                               "We propose the following solution: \n"
                               +
                               solution;

                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "TDINamite420");
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);

                CustomOkMessageBox box = new CustomOkMessageBox("Email sent to " + to + " !");
                box.Show();
            }
            catch (Exception ex)
            {
                CustomOkMessageBox box = new CustomOkMessageBox(ex.ToString());
                box.Show();
            }
        }
Ejemplo n.º 4
0
        // Submit question
        private void button11_Click(object sender, EventArgs e)
        {
            if (TicketSelected())
            {
                int             selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow      = dataGridView1.Rows[selectedrowindex];
                string          id = Convert.ToString(selectedRow.Cells["Id"].Value);

                DataTable secondaryTickets = proxy.GetSecondaryTicketsBySolver(username);
                for (int i = 0; i < secondaryTickets.Rows.Count; i++)
                {
                    if (secondaryTickets.Rows[i][1].Equals(id))
                    {
                        List <string> q = new List <string>();
                        List <string> a = new List <string>();

                        int questionAndAnswersSize = secondaryTickets.Columns.Count - 6;


                        for (int u = 1; u <= questionAndAnswersSize; u++)
                        {
                            a.Add(Convert.ToString(secondaryTickets.Rows[i][secondaryTickets.Columns.Count - u].ToString()));
                            u++;
                            q.Add(Convert.ToString(secondaryTickets.Rows[i][secondaryTickets.Columns.Count - u].ToString()));
                        }

                        q.Add(textBox3.Text);
                        a.Add("waiting for answer");

                        proxy.AddSecondaryTicketNewQuestions((string)secondaryTickets.Rows[i][0], (string)secondaryTickets.Rows[i][1], username, textBox4.Text, textBox2.Text, q, a);

                        textBox2.Text = "";
                        textBox3.Text = "";
                        textBox4.Text = "";
                        return;
                    }
                }

                proxy.AddSecondaryTicket(id, username, textBox4.Text, textBox2.Text, textBox3.Text);

                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
            }
            else
            {
                CustomOkMessageBox box = new CustomOkMessageBox("It's better if you assign select one ticket at time!");
                box.Show();
            }
        }
Ejemplo n.º 5
0
        // View by username
        private void button1_Click(object sender, EventArgs e)
        {
            if (state == 2)
            {
                users = proxy.GetUsers();
                listBox2.Items.Clear();

                for (int i = 0; i < users.Rows.Count; i++)
                {
                    listBox2.Items.Add(users.Rows[i][1]);
                }

                listBox2.Visible      = true;
                dataGridView1.Visible = true;
                button5.Visible       = false;
                button6.Visible       = true;
                //dataGridView1.Location = new Point(190, 140);
                //dataGridView1.Size = new Size(618, 244);

                if (listBox2.Items.Count == 0)
                {
                    CustomOkMessageBox box = new CustomOkMessageBox("There are no users registed !");
                    box.Show();
                    return;
                }

                if (listBox2.SelectedIndex == -1)
                {
                    listBox2.SelectedIndex = 0;
                }

                UpdateUserTickets();
            }
            else if (state == 6)
            {
                DataTable dt       = proxy.GetSecondaryTicketsBySolver(username);
                string    ticketId = textBox4.Text;

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if ((string)dt.Rows[i][1] != ticketId)
                    {
                        dt.Rows.RemoveAt(i);
                        i--;
                    }
                }

                dataGridView2.DataSource = dt;
            }
        }
Ejemplo n.º 6
0
        private void PollingEvent(Object source, System.Timers.ElapsedEventArgs e)
        {
            DataTable             dt         = proxy.GetSecondaryTicketsBySolver(username);
            List <List <string> > newAnswers = new List <List <string> >();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                object[]      row     = dt.Rows[i].ItemArray;
                List <string> newList = new List <string>();

                for (int j = 0; j < row.Length; j++)
                {
                    string value = "";
                    try
                    {
                        value = (string)row[j];
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }

                    if (dt.Columns[j].ColumnName.StartsWith("answer"))
                    {
                        newList.Add(value);
                    }
                }

                newAnswers.Add(newList);
            }

            // Compare
            bool leave = false;

            if (answers != null)
            {
                for (int i = 0; i < answers.Count && i < newAnswers.Count; i++)
                {
                    for (int j = 0; j < answers[i].Count && j < newAnswers[i].Count; j++)
                    {
                        if (answers[i][j] != newAnswers[i][j])
                        {
                            InvokeIfRequired(() =>
                            {
                                CustomOkMessageBox box = new CustomOkMessageBox($"The secondary ticket \n'{dt.Rows[i][0]}'\n has been answered !");
                                box.Show();
                            });

                            leave = true;
                            break;
                        }
                    }

                    if (leave)
                    {
                        break;
                    }
                }
            }

            answers = newAnswers;
        }