Пример #1
0
        public void AgregarCanal(DTOChannel channel, String type)
        {
            string sSel;
            string sSelCount;
            bool   exist;

            sSelCount = "SELECT COUNT(*) FROM \"tbl_Channel\" WHERE \"idChannel\"=" + channel.IdChannel;
            NpgsqlDataAdapter daCount;
            DataSet           dtCount = new DataSet();

            try
            {
                daCount = new NpgsqlDataAdapter(sSelCount, sConexion);
                daCount.Fill(dtCount);
                if (dtCount.Tables[0].Rows[0][0].ToString() == "0")
                {
                    exist = false;
                }
                else
                {
                    exist = true;
                }
            }
            catch (Exception)
            {
                exist = false;
            }


            if (!exist)
            {
                string            sSelIdTipo = "SELECT \"tbl_ChannelType\".\"idType\" FROM \"tbl_ChannelType\" WHERE \"tbl_ChannelType\".\"channelType\" = '" + type + "'";
                NpgsqlDataAdapter daIdTipo;
                DataSet           dtIdTipo = new DataSet();
                string            idTipo   = "";
                try
                {
                    daIdTipo = new NpgsqlDataAdapter(sSelIdTipo, sConexion);
                    daIdTipo.Fill(dtIdTipo);
                    idTipo = dtIdTipo.Tables[0].Rows[0][0].ToString();
                }
                catch (Exception)
                {
                }

                sSel = "INSERT INTO \"tbl_Channel\" VALUES(" + channel.IdChannel + ",'" + channel.CallLetter + "','" + channel.ChannelName.Replace("'", "") + "'," + idTipo + ");";

                NpgsqlDataAdapter da;
                DataSet           dt = new DataSet();

                try
                {
                    da = new NpgsqlDataAdapter(sSel, sConexion);
                    da.Fill(dt);
                }
                catch (Exception)
                {
                }
            }
        }
Пример #2
0
        static void InsertChannel(XmlDocument xmlDoc)
        {
            try
            {
                Console.WriteLine("Canales");
                DTOChannel  canal    = new DTOChannel();
                XmlNodeList channels = xmlDoc.GetElementsByTagName("glf")[0].ChildNodes[2].ChildNodes;

                foreach (XmlNode channel in channels)
                {
                    canal.IdChannel   = Int64.Parse(channel.Attributes["id"].Value);
                    canal.CallLetter  = channel.Attributes["c"].Value;
                    canal.ChannelName = channel.Attributes["l"].Value;
                    conexion.AgregarCanal(canal, channel.Attributes["t"].Value);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }