Ejemplo n.º 1
0
        private void carregaListaCargosDisco()
        {
            ListaCargos cargos = new ListaCargos();

            Cursor.Current = Cursors.WaitCursor;

            XmlSerializer serializer;
            FileStream fs = null;

            // buscando lista no disco
            try
            {
                if (File.Exists(Config.PastaXML + "\\Cargos.xml"))
                {
                    serializer = new XmlSerializer(typeof(ListaCargos));
                    fs = new FileStream(Config.PastaXML + "\\Cargos.xml", FileMode.Open);
                    cargos = (ListaCargos)serializer.Deserialize(fs);
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                // Erro buscando lista.
                Console.WriteLine(ex.StackTrace);

            }
            finally
            {
                if (fs != null)
                    fs.Dispose();

            }

            cbListaCargos.Items.Clear();
            foreach (Cargo c in cargos.Cargos)
                cbListaCargos.Items.Add(c);

            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 2
0
        private void salvarListaCargos(ListaCargos lista)
        {
            XmlSerializer serializer;
            FileStream fs = null;

            // Salvando XML novo
            try
            {
                if (File.Exists(Config.PastaXML + "\\Cargos.xml"))
                    File.Delete(Config.PastaXML + "\\Cargos.xml");

                serializer = new XmlSerializer(typeof(ListaCargos));
                fs = new FileStream(Config.PastaXML + "\\Cargos.xml", FileMode.OpenOrCreate);
                serializer.Serialize(fs, lista);
                fs.Close();
            }
            catch (Exception ex)
            {
                // Erro salvando xml
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                if (fs != null)
                    fs.Dispose();
            }
        }
Ejemplo n.º 3
0
        private void carregaListaCargosUsuarioDisco()
        {
            Cursor.Current = Cursors.WaitCursor;

            XmlSerializer serializer;
            FileStream fs = null;

            // buscando lista no disco
            try
            {
                if (File.Exists(Config.PastaXML + "\\CargosUsuario.xml"))
                {
                    serializer = new XmlSerializer(typeof(ListaCargos));
                    fs = new FileStream(Config.PastaXML + "\\CargosUsuario.xml", FileMode.Open);
                    listacargosusuario = (ListaCargos)serializer.Deserialize(fs);
                    fs.Close();
                }
            }
            catch (Exception ex)
            {
                // Erro buscando lista.
                Console.WriteLine(ex.StackTrace);

            }
            finally
            {
                if (fs != null)
                    fs.Dispose();

            }

            foreach (Cargo c in listacargosusuario.Cargos)
            {
                TabPage t = new TabPage(c.Nome);

                ucPainelListaConcurso uc = new ucPainelListaConcurso();
                uc.Dock = DockStyle.Fill;
                uc.setCargo(c);
                uc.ConcursoAdicionado += uc_ConcursoAdicionado;
                t.Controls.Add(uc);
                tabs.TabPages.Add(t);

                tabs.SelectedIndex = tabs.TabPages.Count - 1;
            }

            Cursor.Current = Cursors.Default;
        }
Ejemplo n.º 4
0
 private void preencheListaCargos(ListaCargos lista)
 {
     if (this.cbListaCargos.InvokeRequired)
     {
         preencheListaCargosCallback d = new preencheListaCargosCallback(preencheListaCargos);
         this.Invoke(d, new object[] { lista });
     }
     else
     {
         foreach (Cargo c in lista.Cargos)
             cbListaCargos.Items.Add(c);
     }
 }
Ejemplo n.º 5
0
        private void carregaListaCargosOnlineThread()
        {
            ListaCargos cargos = new ListaCargos();

            Cursor.Current = Cursors.WaitCursor;

            // Buscando lista no site
            try
            {
                WebRequest req = HttpWebRequest.Create("http://www.pciconcursos.com.br/formacao/");
                req.Method = "GET";

                HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
                doc.Load(req.GetResponse().GetResponseStream(), Encoding.UTF8);

                foreach (HtmlNode c in doc.DocumentNode.SelectNodes("//ul[@class='formacoes']//li//a"))
                    cargos.Cargos.Add(new Cargo() { Nome = c.InnerText, Link = c.GetAttributeValue("href", string.Empty) });

                salvarListaCargos(cargos);
            }
            catch (Exception ex)
            {
                // Erro buscando lista.
                Console.WriteLine(ex.StackTrace);
            }

            preencheListaCargos(cargos);
        }