Ejemplo n.º 1
0
        public IHttpActionResult PutTicket(int id, string reporter, string message)
        {
            try
            {
                //Use Put to create or replace
                var ticket = db.TICKETS.FirstOrDefault((p) => p.Id == id);
                if (ticket == null)
                {
                    ticket = new TICKET(id, reporter, message);
                    db.TICKETS.Add(ticket);
                    db.SaveChanges();
                    return(Ok(ticket));
                }
                else
                {
                    ticket.Message  = message;
                    ticket.Reporter = reporter;
                    db.TICKETS.Attach(ticket);
                    var entry = db.Entry(ticket);
                    entry.Property(e => e.Message).IsModified  = true;
                    entry.Property(e => e.Reporter).IsModified = true;
                    db.SaveChanges();

                    return(Ok(ticket));
                }
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.InternalServerError, e.Message));
            }
        }
Ejemplo n.º 2
0
 public ActionResult Create([Bind(Include = "TicketGuid,TicketNumber,Summary,Description,CreationDate," +
                                            "Creator,ClosedDate,TicketPriority,ClosingComments")] Ticket ticket)
 {
     if (ModelState.IsValid)
     {
         ticket.TicketGuid   = Guid.NewGuid();
         ticket.TicketNumber = db.Tickets.Max(t => t.TicketNumber) + 1;
         ticket.CreationDate = DateTime.Now;
         db.Tickets.Add(ticket);
         db.SaveChanges();
         TempData["Message"] = "Ticket successfully created!";
         return(RedirectToAction("Index"));
     }
     return(View(ticket));
 }
 private void GetTickets()
 {
     using (var ctx = new TicketsEntities())
     {
         var query = from t in ctx.vi_Ticket
                     where t.ticketState != "closed"
                     select t;
         //
         foreach (var ticket in query)
         {
             dgv_tickets.Rows.Add(
                 ticket.cod,
                 ticket.ticketState,
                 ticket.ticketDescription,
                 ticket.ticketPriority,
                 ticket.ticketType,
                 ticket.ticketUser,
                 ticket.creationDate,
                 ticket.technician,
                 ticket.closeDate
                 );
         }
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 4
0
        private void doAction()
        {
            using (var ctx = new TicketsEntities())
            {
                int tech_num = Convert.ToInt16(textBox_techCode.Text);
                //output paramenter
                ObjectParameter objParam = new ObjectParameter("cod", typeof(String));

                ctx.proc_Assign_Technician(tech_num, objParam);
                String ticket_code = Convert.ToString(objParam.Value);
                if (ticket_code.Equals("."))
                {
                    MessageBox.Show("The Technician with number " + tech_num + " doesn't exist in the DB");
                }
                else
                {
                    if (ticket_code.Equals(""))
                    {
                        MessageBox.Show("There are no unassigned Tickets.");
                    }
                    else
                    {
                        MessageBox.Show("The Technician with number " + tech_num + " has been assigned to Ticket " + ticket_code);
                    }
                }
                //
                ctx.SaveChanges();
            }
        }
        private void GetTicketInfo()
        {
            using (var ctx = new TicketsEntities())
            {
                bool   reveal      = true;
                String ticket_code = textBox_ticketCode.Text;
                //
                // get ticket steps
                //
                var result = ctx.proc_Get_Ticket_Steps(ticket_code);
                var q      = result.ToList();

                //

                if (q.Count() == 0)
                {
                    //if ticket code doesn't exist, hides the insertion section
                    Conceal();
                    dgv_steps.Rows.Clear();
                    MessageBox.Show("There isn't any ticket with the code " + ticket_code);
                }
                else
                {
                    foreach (var line in q)
                    {
                        if (!line.ticketState.Equals("In Progress"))
                        {
                            dgv_steps.Rows.Clear();
                            MessageBox.Show("The ticket " + ticket_code + " is not in progress");
                            Conceal();
                            reveal = false;
                            break;
                        }
                        dgv_steps.Rows.Add(
                            line.orderNumber,
                            line.description
                            );
                        //stores the responsible technician for the ticket, for future use
                        resp_technician = Convert.ToInt32(line.technician);
                        //stores the ticket's ticket type for future use
                        ticket_type = line.ticketType;
                    }
                    if (reveal)
                    {
                        Reveal();
                    }
                }
                //
                ctx.SaveChanges();
            }
        }
 private void DoInsertion()
 {
     using (var ctx = new TicketsEntities())
     {
         //
         // insert ticket action
         //
         String ticketCode      = textBox_ticketCode.Text;
         int    tech            = Convert.ToInt32(textBox_techNum.Text);
         String ticketType      = ticket_type;
         int    stepOrderNumber = Convert.ToInt32(textBox_stepNum.Text);
         String note            = textBox_actionNote.Text;
         //output paramenter
         ObjectParameter objParam = new ObjectParameter("orderNumber", typeof(int));
         ctx.sp_Insert_Ticket_Action(ticketCode, tech, ticketType, stepOrderNumber, note, objParam);
         //
         if (MessageBox.Show("When you press Ok, the action will be closed", "Confirm", MessageBoxButtons.OK) == DialogResult.OK)
         {
             //
             // end ticket action
             //
             ctx.sp_End_Ticket_Action(Convert.ToInt32(objParam.Value), ticketCode);
             //
             if (MessageBox.Show("Did the action solve the problem?", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 if (resp_technician == Convert.ToInt32(textBox_techNum.Text))
                 {
                     //
                     // close ticket
                     //
                     ctx.sp_Close_Ticket(ticketCode, tech);
                     MessageBox.Show("The ticket " + ticketCode + " has been closed.");
                 }
                 else
                 {
                     MessageBox.Show("You're not the technician responsible for this ticket, so it's not closed.");
                 }
                 dgv_steps.Rows.Clear();
             }
         }
         //
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 7
0
 private void doAction()
 {
     using (var ctx = new TicketsEntities())
     {
         String ticketCode = textBox_cod.Text;
         //output paramenter
         ObjectParameter objParam = new ObjectParameter("res", typeof(int));
         ctx.proc_Remove_Ticket(ticketCode, objParam);
         // proc output that indicates success
         int r = Convert.ToInt32(objParam.Value);
         if (r == 0)
         {
             MessageBox.Show("The ticket with code " + ticketCode + "does not exist or has already been removed.");
         }
         else
         {
             MessageBox.Show("The ticket with code " + ticketCode + "has been removed");
         }
         //
         ctx.SaveChanges();
     }
 }
 //button export click event
 private void btn_export_Click(object sender, EventArgs e)
 {
     using (var ctx = new TicketsEntities())
     {
         DataSet ds = new DataSet();
         // get desired ticket
         String ticketCod = textBox_ticketCode.Text;
         //reads XML_Schema to build dataset
         ds.ReadXmlSchema("XML_Schema.xsd");
         DataTableCollection dtc = ds.Tables;
         //
         var result = ctx.proc_Get_Ticket_Info(ticketCod);
         //populate dataset
         int i = 0;
         foreach (var ticket in result)
         {
             if (i == 0)
             {
                 // ticket info
                 dtc["ticket"].Rows.Add(new Object[] { ticket.tt_id, ticket.cod, ticket.ticketState, ticket.ticketDescription, 1 });
                 dtc["owner"].Rows.Add(new Object[] { ticket.owner_email, ticket.owner_name, ticket.owner_id, ticket.owner_email, 1 });
                 dtc["supervisor"].Rows.Add(new Object[] { ticket.anumber, ticket.tech_name, ticket.tech_email, ticket.anumber, 1 });
                 dtc["type_type"].Rows.Add(new Object[] { ticket.tt_id, ticket.tt_name, ticket.tt_id, 1 });
                 // ticket actions sequence
                 dtc["actions"].Rows.Add(new object[] { 1 });
                 ++i;
             }
             // continues until there's no more actions
             dtc["action"].Rows.Add(new object[] { ticket.orderNumber, ticket.beginDate, ticket.endDate, ticket.orderNumber, 1 });
         }
         ds.DataSetName = "Ticket_Info";
         //saves both xsd and xml
         ds.WriteXml(textBox_filename.Text + ".xml");
         ds.WriteXmlSchema(textBox_filename.Text + ".xsd");
         MessageBox.Show("The ticket " + textBox_ticketCode.Text + " has been exported to " + textBox_filename + ".xml");
         //
         ctx.SaveChanges();
     }
 }