public List <Probleme> find_probleme(SqlDataReader sql)
        {
            List <Probleme>             problemes = new List <Probleme>();
            Dictionary <string, string> id        = new Dictionary <string, string>();
            Categorie c = new Categorie();

            this.connect();
            SqlDataReader result = sql;

            while (result.Read())
            {
                id["IdCategorie"] = "" + result.GetInt32(3);
                c = c.find_by_id(id);

                problemes.Add(new Probleme(
                                  result.GetInt32(0),
                                  result.GetString(1),
                                  result.GetString(2),
                                  c
                                  ));
            }
            this.disconnect();

            return(problemes);
        }
Пример #2
0
        public IEnumerable <Ticket> GetAllTickets()
        {
            var tickets = new List <Ticket>();

            using (this.connexion = new SqlConnection(_connString))
            {
                this.connexion.Open();
                using (var command = new SqlCommand(@"SELECT [IdTicket],[DateOuverture],[DateFermeture],[Objet],[Description],[Priorite],[IdCategorie],[IdUser],[EtatTicket] FROM [dbo].[Ticket] ORDER BY [IdTicket] DESC", this.connexion))
                {
                    command.Notification = null;

                    var dependency = new SqlDependency(command);
                    dependency.OnChange += new OnChangeEventHandler(dependency_OnChange);

                    if (this.connexion.State == System.Data.ConnectionState.Closed)
                    {
                        this.connexion.Open();
                    }

                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        Utilisateur utilisateur = new Utilisateur();
                        Categorie   categorie   = new Categorie();

                        Dictionary <string, string> id2 = new Dictionary <string, string>();
                        Dictionary <string, string> id3 = new Dictionary <string, string>();

                        id2["IdUser"] = "" + (int)reader["IdUser"];
                        utilisateur   = utilisateur.find_by_id(id2);

                        id3["[IdCategorie]"] = "" + (int)reader["IdCategorie"];
                        categorie            = categorie.find_by_id(id3);

                        tickets.Add(new Ticket((int)reader["IdTicket"], Convert.ToDateTime(reader["DateOuverture"]), Convert.ToDateTime(reader["DateFermeture"]), (string)reader["Objet"], (string)reader["Description"], (string)reader["Priorite"], utilisateur, categorie, (string)reader["EtatTicket"]));

                        // tickets.Add(item: new Ticket { IdTicket = (int)reader["IdTicket"],DateOuverture = Convert.ToDateTime(reader["DateOuverture"]),DateFermeture = Convert.ToDateTime(reader["DateFermeture"]),Objet = (string)reader["Objet"],Description = (string)reader["Description"] });
                    }

                    this.connexion.Close();
                    this.connexion.Dispose();
                    SqlConnection.ClearPool(this.connexion);
                }
            }

            return(tickets);
        }
        public List <Ticket> find_ticket(SqlDataReader sql)
        {
            Utilisateur utilisateur = new Utilisateur();
            Categorie   c           = new Categorie();

            Dictionary <string, string> id2 = new Dictionary <string, string>();
            Dictionary <string, string> id3 = new Dictionary <string, string>();

            List <Ticket> tickets = new List <Ticket>();

            this.connect();
            SqlDataReader result = sql;

            while (result.Read())
            {
                id2["IdUser"] = "" + result.GetInt32(7);
                utilisateur   = utilisateur.find_by_id(id2);

                id3["[IdCategorie]"] = "" + result.GetInt32(6);
                c = c.find_by_id(id3);

                tickets.Add(new Ticket(
                                result.GetInt32(0),
                                result.GetDateTime(1),
                                result.GetDateTime(2),
                                result.GetString(3),
                                result.GetString(4),
                                result.GetString(5),
                                utilisateur,
                                c,
                                result.GetString(8)
                                ));
            }
            this.disconnect();
            return(tickets);
        }