using MySql.Data.MySqlClient; public class MySQLDBConnector { private MySqlConnection connection; private string server; private string database; private string uid; private string password; //Constructor public MySQLDBConnector() { Initialize(); } //Initialize values private void Initialize() { server = "10.0.x.x"; // "otrs.chatham.teksavvy.ca"; database = "otrs"; uid = "xxxx"; password = "xxxx"; string connectionString = "SERVER=" + server + ";Port=3306;" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";"; connection = new MySqlConnection(connectionString); } //open connection to database public bool OpenConnection() { try { connection.Open(); return true; } catch (MySqlException ex) { switch (ex.Number) { } return false; } } public int Count() { string query = @"select count(*) from ticket inner join queue on ticket.queue_id= queue.id inner join ticket_state on ticket_state.id = ticket.ticket_state_id where queue.name ='Junk' and ticket.ticket_state_id = 4"; ; int Count = -1; //Open Connection if (this.OpenConnection() == true) { //Create Mysql Command MySqlCommand cmd = new MySqlCommand(query, connection); //ExecuteScalar will return one value Count = int.Parse(cmd.ExecuteScalar() + ""); //close Connection connection.Close(); return Count; } else { return Count; } } }
Tuesday, July 30, 2013
How to get Open ticket number for one queue in OTRS MySQL database by .Net ?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment