public int OpenTicket(Ticket ticket) { throw new NotImplementedException("TODO"); }
public Ticket PullFullTicket(TicketStub stub) { MySqlConnection dataBase = new MySqlConnection(connectionString); MySqlCommand pullThreadsCommand = new MySqlCommand("SELECT * FROM `ost_ticket_thread` WHERE `ticket_id` = " + stub.trueNumber + ";", dataBase); Ticket newTicket = new Ticket(stub); try { dataBase.Open(); MySqlDataReader reader = pullThreadsCommand.ExecuteReader(); newTicket.responses = new List<Message>(); while (reader.Read()) { Message currentMessage = new Message(); currentMessage.responseNumber = reader.GetInt32("id"); currentMessage.threadType = reader.GetChar("thread_type"); currentMessage.posterName = reader.GetString("poster"); currentMessage.messageTitle = reader.GetString("title"); currentMessage.messageData = reader.GetString("body"); currentMessage.timeRecieved = DateTime.Parse(reader.GetString(Constants.creationDate)); newTicket.responses.Add(currentMessage); } reader.Close(); } catch (Exception) { throw; } finally { dataBase.Close(); } return newTicket; }
public void ReplyToTicket(Ticket ticketToRespondTo, Message messageToReplyWith) { MySqlConnection database = new MySqlConnection(connectionString); //MySqlCommand appendResponse = new MySqlCommand("INSERT INTO `ost_ticket_thread` VALUES (DEFAULT // ,@pid,@trueticketid,@staffid,@userid,@threadtype,@poster,@source,@title,@body,@ipadd,@created, DEFAULT, DEFAULT)", database); StringBuilder replyQuery = new StringBuilder(); replyQuery.Append("INSERT INTO `ost_ticket_thread` VALUES ("); replyQuery.Append("DEFAULT,"); // To auto increment to responseID replyQuery.Append(String.Format("{0}, {1}, {2},", "0", ticketToRespondTo.trueNumber, "0" )); //pid, true ticket number and TODO: implement staff id's replyQuery.Append(String.Format("{0}, \'{1}\', \"{2}\",", "0", messageToReplyWith.threadType, messageToReplyWith.posterName)); // userid, threadType, poster replyQuery.Append(String.Format("\"{0}\", \"{1}\", \"{2}\",", "TICKET_APP" , messageToReplyWith.messageTitle, messageToReplyWith.messageData)); //source, title, body replyQuery.Append(String.Format("{0}, \"{1}\", DEFAULT);", "DEFAULT", DateTime.Now.ToString("yyyy-MM-dd HH:mm:tt"))); // ip add, Created Time, Updated time TODO: Implement ip addr MySqlCommand appendResponse = new MySqlCommand(replyQuery.ToString(), database); try { database.Open(); appendResponse.ExecuteNonQuery(); } catch (Exception) { throw; } finally { database.Close(); } }