예제 #1
0
        public void InsertRole(int fk_ref_film, XMLRoleData role)
        {
            string cmd_string = @"INSERT INTO FILM_ACTEUR (FK_PERSONNEID,FK_FILMID,PERSONNAGE) 
                                                VALUES(" + role.ref_personne_bd_id + "," + fk_ref_film + ",'" + role.personnage_name + "')";

            OracleCommand cmd = new OracleCommand(cmd_string, m_connection);

            cmd.CommandType = CommandType.Text;
            cmd.ExecuteReader();
            cmd = null;
        }
예제 #2
0
        static void FetchFilmData(FileStream xml_file,
                                  List <XMLFilmData> list_data)
        {
            Console.WriteLine("Fetching film data ");
            XmlReader r = XmlReader.Create(xml_file);

            XMLFilmData c_f_data    = null;
            XMLRoleData curren_role = null;

            String c_node_name = "";

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element)
                {
                    c_node_name = r.Name;
                    switch (c_node_name)
                    {
                    case "acteur":
                    {
                        if (r.HasAttributes)
                        {
                            curren_role.xml_personne_id = System.Convert.ToInt32(r.GetAttribute(0));
                        }

                        //Console.WriteLine("\t Attribute: " + c_f_data.realisateur_xml_id);

                        break;
                    }

                    case "role":
                    {
                        if (curren_role == null)
                        {
                            curren_role = new XMLRoleData();
                        }
                        else
                        {
                            c_f_data.roles_list.Add(curren_role);
                            curren_role = null;
                            curren_role = new XMLRoleData();
                        }

                        break;
                    }

                    case "realisateur":
                    {
                        if (r.HasAttributes)
                        {
                            c_f_data.realisateur_xml_id = System.Convert.ToInt32(r.GetAttribute(0));
                        }

                        //Console.WriteLine("\t Attribute: " + c_f_data.realisateur_xml_id);
                        break;
                    }

                    case "film":
                    {
                        //Console.WriteLine("<" + c_node_name + ">");
                        if (c_f_data != null)
                        {
                            list_data.Add(c_f_data);
                            c_f_data    = null;
                            c_f_data    = new XMLFilmData();
                            curren_role = null;
                        }
                        else
                        {
                            c_f_data = new XMLFilmData();
                        }
                        if (r.HasAttributes)
                        {
                            c_f_data.xml_id = System.Convert.ToInt32(r.GetAttribute(0));
                        }
                        break;
                    }

                    default:
                    {
                        //Console.WriteLine("<" + c_node_name + ">");

                        bool result = r.Read();
                        if (result == true)
                        {
                            if (r.NodeType == XmlNodeType.Text)
                            {
                                if (c_node_name == "titre")
                                {
                                    c_f_data.title = r.Value;
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "annee")
                                {
                                    c_f_data.year = System.Convert.ToInt32(r.Value);
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "pays")
                                {
                                    c_f_data.pays = r.Value;
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "langue")
                                {
                                    c_f_data.langue = r.Value;
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "duree")
                                {
                                    c_f_data.duree = System.Convert.ToInt32(r.Value);
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "resume")
                                {
                                    c_f_data.resumer = r.Value;
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "genre")
                                {
                                    c_f_data.genre_list.Add(r.Value);
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "scenariste")
                                {
                                    c_f_data.scenariste_list.Add(r.Value);
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                                if (c_node_name == "personnage")
                                {
                                    curren_role.personnage_name = r.Value;
                                    //Console.WriteLine("\tVALUE: " + r.Value);
                                }
                            }
                        }
                        else
                        {
                            r.Read();
                        }
                        break;
                    }
                    }
                }
            }
            // Add the last one manualy
            if (curren_role != null)
            {
                c_f_data.roles_list.Add(curren_role);
            }
            //Add the last one manualy
            if (c_f_data != null)
            {
                list_data.Add(c_f_data);
            }
            Console.WriteLine("Fetching film data completed");
        }